Skip to content

Commit

Permalink
DEP: remove/fix deprecated objects/command (columncolab#124)
Browse files Browse the repository at this point in the history
* DEP: remove/fix deprecated objects/command
  • Loading branch information
isilber authored Nov 4, 2024
1 parent a7f381e commit 6ef8534
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions emc2/core/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def num_subcolumns(self):
Gets the number of subcolumns in the model. Will
return 0 if the number of subcolumns has not yet been set.
"""
if 'subcolumn' in self.ds.dims.keys():
if 'subcolumn' in self.ds.dims:
return self.ds.dims['subcolumn']
else:
return 0
Expand Down Expand Up @@ -378,15 +378,15 @@ def check_and_stack_time_lat_lon(self, out_coord_name="time_lat_lon", file_path=
do_process = 0 # 0 - do nothing, 1 - stack lat+lon, 2 - stack lat dim only

# Add time dimension for processing (remove later if length = 1)
if not self.time_dim in [x for x in self.ds.dims.keys()]:
if not self.time_dim in [x for x in self.ds.dims]:
self.ds = self.ds.expand_dims(self.time_dim)

# Check to make sure we are loading a single column
if self.lat_dim in [x for x in self.ds.dims.keys()]:
if self.ds.dims[self.lat_dim] != 1:
if self.lat_dim in [x for x in self.ds.dims]:
if self.ds.sizes[self.lat_dim] != 1:
do_process = 1
if self.lon_dim in [x for x in self.ds.dims.keys()]:
if self.ds.dims[self.lon_dim] != 1:
if self.lon_dim in [x for x in self.ds.dims]:
if self.ds.sizes[self.lon_dim] != 1:
do_process = 1
elif do_process == 1:
do_process = 2
Expand All @@ -411,7 +411,7 @@ def check_and_stack_time_lat_lon(self, out_coord_name="time_lat_lon", file_path=
self.ds = self.ds.stack({out_coord_name: (self.lat_dim, self.time_dim)})
self.stacked_time_dim, self.time_dim = self.time_dim, out_coord_name
else:
if self.lon_dim in [x for x in self.ds.dims.keys()]:
if self.lon_dim in [x for x in self.ds.dims]:
# No need for lat and lon dimensions
self.ds = self.ds.squeeze(dim=(self.lat_dim, self.lon_dim))
else:
Expand Down
2 changes: 1 addition & 1 deletion emc2/io/load_mie_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def load_mie_file(filename):
descriptive metadata.
"""

my_df = pd.read_csv(filename, delim_whitespace=True,
my_df = pd.read_csv(filename, sep='\s+',
names=["wavelength", "p_diam", "size_parameter", "compre_real",
"compre_im", "scat_p", "alpha_p", "beta_p", "scat_eff",
"ext_eff", "backscat_eff"])
Expand Down
22 changes: 11 additions & 11 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_plot_timeseries():
model_display.plot_subcolumn_timeseries('sub_col_Ze_cl_strat', 2, subplot_index=(1, 0))
model_display.plot_subcolumn_timeseries('sub_col_Ze_cl_strat', 3, subplot_index=(0, 1))
model_display.plot_subcolumn_timeseries('sub_col_Ze_cl_strat', 4, subplot_index=(1, 1))
return model_display.fig
assert model_display.fig


@pytest.mark.mpl_image_compare(tolerance=30)
Expand All @@ -21,7 +21,7 @@ def test_plot_single_time():

model_display = emc2.plotting.SubcolumnDisplay(model, ds_name="ModelE", figsize=(10, 10))
model_display.plot_single_profile('sub_col_Ze_cl_strat', time='2016-08-16T09:30:00')
return model_display.fig
assert model_display.fig


@pytest.mark.mpl_image_compare(tolerance=30)
Expand All @@ -30,7 +30,7 @@ def test_plot_profile():

model_display = emc2.plotting.SubcolumnDisplay(model, ds_name="ModelE", figsize=(10, 10))
model_display.plot_subcolumn_mean_profile('sub_col_Ze_cl_strat', time='2016-08-16T09:30:00')
return model_display.fig
assert model_display.fig


@pytest.mark.mpl_image_compare(tolerance=30)
Expand All @@ -44,7 +44,7 @@ def test_plot_instrument():
subplot_index=(0, 0), vmin=0.0, vmax=0.5)
model_display.plot_instrument_timeseries(HSRL, "beta_a_backscat", log_plot=True, cmap='magma',
subplot_index=(0, 1), vmin=1e-8, vmax=1e-3)
return model_display.fig
assert model_display.fig


@pytest.mark.mpl_image_compare(tolerance=30)
Expand All @@ -55,7 +55,7 @@ def test_plot_instrument_profile():

model_display = emc2.plotting.SubcolumnDisplay(model, ds_name="ModelE", figsize=(10, 10))
model_display.plot_instrument_mean_profile(HSRL, 'linear_depol', pressure_coords=False)
return model_display.fig
assert model_display.fig


@pytest.mark.mpl_image_compare(tolerance=30)
Expand All @@ -66,7 +66,7 @@ def test_plot_classification():
_, cb = model_display.plot_subcolumn_timeseries('phase_mask_KAZR_sounding_all_hyd', 1)
model_display.change_plot_to_class_mask(cb, variable="phase_mask_KAZR_sounding_all_hyd",
class_legend=["Cloud", "precip", "mixed"])
return model_display.fig
assert model_display.fig


@pytest.mark.mpl_image_compare(tolerance=30)
Expand Down Expand Up @@ -104,7 +104,7 @@ def test_plot_SR_subcol_timeseries():
Ncolumns, Npoints, Nlevels, Nglevels, col_num, newgrid_bot, newgrid_top)
emc2.statistics_LLNL.statistical_plots.plot_every_subcolumn_timeseries_SR(
my_e3sm, atb_total_4D, atb_mol_4D, col_index, '', '', 'addpl_rad')
return plt.gcf()
assert plt.gcf()


@pytest.mark.mpl_image_compare(tolerance=30)
Expand Down Expand Up @@ -164,7 +164,7 @@ def test_plot_get_CFAD_SR():
cfadSR_cal_alltime = np.nanmean(cfadSR_cal_alltime_col, axis=2)
emc2.statistics_LLNL.statistical_plots.plot_lidar_SR_CFAD(
SR_EDGES, newgrid_mid, cfadSR_cal_alltime, '', '', 'addpl_rad')
return plt.gcf()
assert plt.gcf()


@pytest.mark.mpl_image_compare(tolerance=30)
Expand Down Expand Up @@ -224,7 +224,7 @@ def test_plot_regridded_CF_timeseries():
CF_3D, newgrid_mid, col_index, y_range=y_range,
cmap=cmap, title='',
vmin=vmin_max[ii][0], vmax=vmin_max[ii][1], cbar_label=cbar_label[ii])
return model_display3.fig
assert model_display3.fig


@pytest.mark.mpl_image_compare(tolerance=30)
Expand Down Expand Up @@ -262,7 +262,7 @@ def test_plot_subcolumn_timeseries():
field_to_plot[ii], subcol_ind, log_plot=log_plot[ii], y_range=y_range,
subplot_index=(0, ii), cmap=cmap, title='',
vmin=vmin_max[ii][0], vmax=vmin_max[ii][1], pressure_coords=False)
return model_display.fig
assert model_display.fig


@pytest.mark.mpl_image_compare(tolerance=30)
Expand All @@ -280,4 +280,4 @@ def test_plotting_every_subcolumn_timeseries_radarlidarsignal():
unstack_dims=True, finalize_fields=True, use_rad_logic=True)
emc2.statistics_LLNL.statistical_plots.plot_every_subcolumn_timeseries_radarlidarsignal(
my_e3sm, col_index, '', '', 'addpl_radiation')
return plt.gcf()
assert plt.gcf()

0 comments on commit 6ef8534

Please sign in to comment.