Skip to content

Commit

Permalink
codes norm and address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
apchoiCMD committed Jan 23, 2024
1 parent 069413a commit 75887db
Showing 1 changed file with 91 additions and 94 deletions.
185 changes: 91 additions & 94 deletions scripts/exgdas_global_marine_analysis_vrfy.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,127 +43,124 @@
HOMEgfs = os.getenv('HOMEgfs')


#######################################
# plot_parallel
#######################################
# plot marine analysis vrfy

def plot_parallel(config):
def plot_marine_vrfy(config):
ocnvrfyPlotter = statePlotter(config)
ocnvrfyPlotter.plot()

#######################################
# Define configurations dynamically
#######################################


configs = [plotConfig(grid_file=grid_file,
data_file=os.path.join(comout, f'{RUN}.t{cyc}z.ocn.recentering_error.nc'),
variables_horiz={'ave_ssh': [-1, 1]},
colormap='seismic',
comout=os.path.join(comout, 'vrfy', 'recentering_error')), # recentering error
data_file=os.path.join(comout, f'{RUN}.t{cyc}z.ocn.recentering_error.nc'),
variables_horiz={'ave_ssh': [-1, 1]},
colormap='seismic',
comout=os.path.join(comout, 'vrfy', 'recentering_error')), # recentering error
plotConfig(grid_file=grid_file,
data_file=os.path.join(comout, f'{RUN}.t{cyc}z.ocn.ssh_steric_stddev.nc'),
variables_horiz={'ave_ssh': [0, 0.8]},
colormap='gist_ncar',
comout=os.path.join(comout, 'vrfy', 'bkgerr', 'ssh_steric_stddev')), # ssh steric stddev
data_file=os.path.join(comout, f'{RUN}.t{cyc}z.ocn.ssh_steric_stddev.nc'),
variables_horiz={'ave_ssh': [0, 0.8]},
colormap='gist_ncar',
comout=os.path.join(comout, 'vrfy', 'bkgerr', 'ssh_steric_stddev')), # ssh steric stddev
plotConfig(grid_file=grid_file,
data_file=os.path.join(comout, f'{RUN}.t{cyc}z.ocn.ssh_unbal_stddev.nc'),
variables_horiz={'ave_ssh': [0, 0.8]},
colormap='gist_ncar',
comout=os.path.join(comout, 'vrfy', 'bkgerr', 'ssh_unbal_stddev')), # ssh unbal stddev
data_file=os.path.join(comout, f'{RUN}.t{cyc}z.ocn.ssh_unbal_stddev.nc'),
variables_horiz={'ave_ssh': [0, 0.8]},
colormap='gist_ncar',
comout=os.path.join(comout, 'vrfy', 'bkgerr', 'ssh_unbal_stddev')), # ssh unbal stddev
plotConfig(grid_file=grid_file,
data_file=os.path.join(comout, f'{RUN}.t{cyc}z.ocn.ssh_total_stddev.nc'),
variables_horiz={'ave_ssh': [0, 0.8]},
colormap='gist_ncar',
comout=os.path.join(comout, 'vrfy', 'bkgerr', 'ssh_total_stddev')), # ssh total stddev
data_file=os.path.join(comout, f'{RUN}.t{cyc}z.ocn.ssh_total_stddev.nc'),
variables_horiz={'ave_ssh': [0, 0.8]},
colormap='gist_ncar',
comout=os.path.join(comout, 'vrfy', 'bkgerr', 'ssh_total_stddev')), # ssh total stddev
plotConfig(grid_file=grid_file,
data_file=os.path.join(comout, f'{RUN}.t{cyc}z.ocn.steric_explained_variance.nc'),
variables_horiz={'ave_ssh': [0, 1]},
colormap='seismic',
comout=os.path.join(comout, 'vrfy', 'bkgerr', 'steric_explained_variance')), # steric explained variance
data_file=os.path.join(comout, f'{RUN}.t{cyc}z.ocn.steric_explained_variance.nc'),
variables_horiz={'ave_ssh': [0, 1]},
colormap='seismic',
comout=os.path.join(comout, 'vrfy', 'bkgerr', 'steric_explained_variance')), # steric explained variance
plotConfig(grid_file=grid_file,
data_file=os.path.join(comout, f'{RUN}.t'+cyc+'z.ocn.bkgerr_stddev.nc'),
lats=np.arange(-60, 60, 10),
lons=np.arange(-280, 80, 30),
variables_zonal={'Temp': [0, 2],
'Salt': [0, 0.2],
'u': [0, 0.2],
'v': [0, 0.2]},
variables_meridional={'Temp': [0, 2],
'Salt': [0, 0.2],
'u': [0, 0.2],
'v': [0, 0.2]},
variables_horiz={'Temp': [0, 2],
'Salt': [0, 0.2],
'u': [0, 0.2],
'v': [0, 0.2],
'ave_ssh': [0, 0.1]},
colormap='jet',
comout=os.path.join(comout, 'vrfy', 'bkgerr')), # ocn bkgerr stddev
data_file=os.path.join(comout, f'{RUN}.t'+cyc+'z.ocn.bkgerr_stddev.nc'),
lats=np.arange(-60, 60, 10),
lons=np.arange(-280, 80, 30),
variables_zonal={'Temp': [0, 2],
'Salt': [0, 0.2],
'u': [0, 0.2],
'v': [0, 0.2]},
variables_meridional={'Temp': [0, 2],
'Salt': [0, 0.2],
'u': [0, 0.2],
'v': [0, 0.2]},
variables_horiz={'Temp': [0, 2],
'Salt': [0, 0.2],
'u': [0, 0.2],
'v': [0, 0.2],
'ave_ssh': [0, 0.1]},
colormap='jet',
comout=os.path.join(comout, 'vrfy', 'bkgerr')), # ocn bkgerr stddev
plotConfig(grid_file=grid_file,
data_file=os.path.join(comout, f'{RUN}.t'+cyc+'z.ocninc.nc'),
lats=np.arange(-60, 60, 10),
lons=np.arange(-280, 80, 30),
variables_zonal={'Temp': [-0.5, 0.5],
'Salt': [-0.1, 0.1]},
variables_horiz={'Temp': [-0.5, 0.5],
'Salt': [-0.1, 0.1],
'ave_ssh': [-0.1, 0.1]},
variables_meridional={'Temp': [-0.5, 0.5],
'Salt': [-0.1, 0.1]},
colormap='RdBu',
comout=os.path.join(comout, 'vrfy', 'incr')), # ocean increment
data_file=os.path.join(comout, f'{RUN}.t'+cyc+'z.ocninc.nc'),
lats=np.arange(-60, 60, 10),
lons=np.arange(-280, 80, 30),
variables_zonal={'Temp': [-0.5, 0.5],
'Salt': [-0.1, 0.1]},
variables_horiz={'Temp': [-0.5, 0.5],
'Salt': [-0.1, 0.1],
'ave_ssh': [-0.1, 0.1]},
variables_meridional={'Temp': [-0.5, 0.5],
'Salt': [-0.1, 0.1]},
colormap='RdBu',
comout=os.path.join(comout, 'vrfy', 'incr')), # ocean increment
plotConfig(grid_file=grid_file,
data_file=os.path.join(comout, f'{RUN}.t'+cyc+'z.ice.incr.nc'),
lats=np.arange(-60, 60, 10),
variables_horiz={'aicen': [-0.2, 0.2],
'hicen': [-0.5, 0.5],
'hsnon': [-0.1, 0.1]},
colormap='RdBu',
projs=['North', 'South'],
comout=os.path.join(comout, 'vrfy', 'incr')), # sea ice increment
data_file=os.path.join(comout, f'{RUN}.t'+cyc+'z.ice.incr.nc'),
lats=np.arange(-60, 60, 10),
variables_horiz={'aicen': [-0.2, 0.2],
'hicen': [-0.5, 0.5],
'hsnon': [-0.1, 0.1]},
colormap='RdBu',
projs=['North', 'South'],
comout=os.path.join(comout, 'vrfy', 'incr')), # sea ice increment
plotConfig(grid_file=grid_file,
data_file=os.path.join(comout, f'{RUN}.t'+cyc+'z.iceana.nc'),
variables_horiz={'aicen': [0.0, 1.0],
'hicen': [0.0, 4.0],
'hsnon': [0.0, 0.5]},
colormap='jet',
projs=['North', 'South', 'Global'],
comout=os.path.join(comout, 'vrfy', 'ana')), # sea ice analysis
data_file=os.path.join(comout, f'{RUN}.t'+cyc+'z.iceana.nc'),
variables_horiz={'aicen': [0.0, 1.0],
'hicen': [0.0, 4.0],
'hsnon': [0.0, 0.5]},
colormap='jet',
projs=['North', 'South', 'Global'],
comout=os.path.join(comout, 'vrfy', 'ana')), # sea ice analysis
plotConfig(grid_file=grid_file,
data_file=os.path.join(com_ice_history, f'{RUN}.t{gcyc}z.icef006.nc'),
variables_horiz={'aice_h': [0.0, 1.0],
'hs_h': [0.0, 4.0],
'hi_h': [0.0, 0.5]},
colormap='jet',
projs=['North', 'South', 'Global'],
comout=os.path.join(comout, 'vrfy', 'bkg')), # sea ice background
data_file=os.path.join(com_ice_history, f'{RUN}.t{gcyc}z.icef006.nc'),
variables_horiz={'aice_h': [0.0, 1.0],
'hs_h': [0.0, 4.0],
'hi_h': [0.0, 0.5]},
colormap='jet',
projs=['North', 'South', 'Global'],
comout=os.path.join(comout, 'vrfy', 'bkg')), # sea ice background
plotConfig(grid_file=grid_file,
data_file=os.path.join(comout, f'{RUN}.t'+cyc+'z.ocnana.nc'),
variables_horiz={'ave_ssh': [-1.8, 1.3],
'Temp': [-1.8, 34.0],
'Salt': [30, 38]},
colormap='jet',
comout=os.path.join(comout, 'vrfy', 'ana')), # ocean surface analysis
data_file=os.path.join(comout, f'{RUN}.t'+cyc+'z.ocnana.nc'),
variables_horiz={'ave_ssh': [-1.8, 1.3],
'Temp': [-1.8, 34.0],
'Salt': [30, 38]},
colormap='jet',
comout=os.path.join(comout, 'vrfy', 'ana')), # ocean surface analysis
plotConfig(grid_file=grid_file,
data_file=os.path.join(com_ocean_history, f'{RUN}.t{gcyc}z.ocnf006.nc'),
variables_horiz={'ave_ssh': [-1.8, 1.3],
'Temp': [-1.8, 34.0],
'Salt': [30, 38]},
colormap='jet',
comout=os.path.join(comout, 'vrfy', 'bkg'))] # ocean surface background
data_file=os.path.join(com_ocean_history, f'{RUN}.t{gcyc}z.ocnf006.nc'),
variables_horiz={'ave_ssh': [-1.8, 1.3],
'Temp': [-1.8, 34.0],
'Salt': [30, 38]},
colormap='jet',
comout=os.path.join(comout, 'vrfy', 'bkg'))] # ocean surface background

# List of functions
plot_functions = [plot_parallel] * len(configs)
# plot_functions = [plot_parallel] * len(configs)

# Number of processes (adjust as needed)
num_processes = min(len(configs), len(plot_functions))
num_processes = len(configs)

# Create a list to store the processes
processes = []

# Iterate over pairs of elements from configs and plot_functions
for config, plot_function in zip(configs[:num_processes], plot_functions[:num_processes]):
process = Process(target=plot_function, args=(config,)) # Pass the entire config as an argument
for config in configs[:num_processes]:
process = Process(target=plot_marine_vrfy, args=(config,)) # Pass the entire config as an argument
process.start()
processes.append(process)

Expand Down

0 comments on commit 75887db

Please sign in to comment.