Skip to content

Commit

Permalink
Fix CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
siiptuo committed Aug 10, 2023
1 parent 68e44ab commit 319fee6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
6 changes: 3 additions & 3 deletions mwrpy/level2/lev2_collocated.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def generate_lev2_single(
("2I01", "2I02", "2P01", "2P03"),
(lwp_file, iwv_file, t_prof_file, abs_hum_file),
):
lev2_to_nc(site, prod, mwr_l1c_file, file.name)
lev2_to_nc(prod, mwr_l1c_file, site=site, output_file=file.name)

with (
netCDF4.Dataset(output_file, "w", format="NETCDF4_CLASSIC") as nc_output,
Expand Down Expand Up @@ -90,10 +90,10 @@ def generate_lev2_multi(site: str, mwr_l1c_file: str, output_file: str):
(temp_file, abs_hum_file, rel_hum_file, t_pot_file, eq_temp_file),
):
lev2_to_nc(
site,
prod,
mwr_l1c_file,
file.name,
site=site,
output_file=file.name,
temp_file=temp_file.name if prod not in ("2P02", "2P03") else None,
hum_file=abs_hum_file.name if prod not in ("2P02", "2P03") else None,
)
Expand Down
8 changes: 4 additions & 4 deletions mwrpy/plots/generate_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
)
from mwrpy.utils import (
isbit,
read_config,
read_nc_field_name,
read_nc_fields,
read_yaml_config,
seconds2hours,
)

Expand Down Expand Up @@ -442,7 +442,7 @@ def _plot_segment_data(ax, data: ma.MaskedArray, name: str, axes: tuple, nc_file
colorbar.set_ticks(np.arange(len(clabel)))
if name == "quality_flag_3":
site = _read_location(nc_file)
_, params = read_yaml_config(site)
params = read_config(site, "params")
clabel[2] = clabel[2] + " (" + str(params["TB_threshold"][1]) + " K)"
clabel[1] = clabel[1] + " (" + str(params["TB_threshold"][0]) + " K)"
colorbar.ax.set_yticklabels(clabel, fontsize=13)
Expand Down Expand Up @@ -854,7 +854,7 @@ def _plot_qf(data_in: ndarray, time: ndarray, fig, nc_file: str):
"""Plot for Level 1 quality flags."""

site = _read_location(nc_file)
_, params = read_yaml_config(site)
params = read_config(site, "params")

fig.clear()
nsub = 4
Expand Down Expand Up @@ -976,7 +976,7 @@ def _plot_tb(
):
"""Plot for microwave brigthness temperatures."""
site = _read_location(nc_file)
_, params = read_yaml_config(site)
params = read_config(site, "params")
frequency = read_nc_fields(nc_file, "frequency")
quality_flag = read_nc_fields(nc_file, "quality_flag")
if name == "tb_spectrum":
Expand Down
7 changes: 4 additions & 3 deletions mwrpy/plots/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
convolve2DFFT,
get_ret_freq,
isbit,
read_config,
read_nc_fields,
read_yaml_config,
seconds2hours,
)

Expand All @@ -33,7 +33,7 @@ def _get_ret_flag(nc_file: str, time: ndarray) -> ndarray:
)
quality_flag = quality_flag[q_ind, :]
site = _read_location(nc_file)
_, params = read_yaml_config(site)
params = read_config(site, "params")

if params["flag_status"][3] == 0:
flag[t_ind[np.sum(isbit(quality_flag[:, freq_ind], 3), axis=1) > 0]] = 1
Expand All @@ -45,7 +45,8 @@ def _get_ret_flag(nc_file: str, time: ndarray) -> ndarray:
def _get_lev1(nc_file: str) -> str:
"""Returns name of lev1 file."""
site = _read_location(nc_file)
global_attributes, params = read_yaml_config(site)
global_attributes = read_config(site, "global_specs")
params = read_config(site, "params")
datef = datetime.strptime(nc_file[-11:-3], "%Y%m%d")
data_out_l1 = params["data_out"] + "level1/" + datef.strftime("%Y/%m/%d/")
lev1_file = (
Expand Down
12 changes: 6 additions & 6 deletions mwrpy/process_mwrpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
date_range,
get_processing_dates,
isodate2date,
read_yaml_config,
read_config,
)

PRODUCT_NAME = {
Expand Down Expand Up @@ -63,10 +63,10 @@ def process_product(prod: str, date: datetime.date, site: str):

if prod[0] == "1":
lev1_to_nc(
site,
prod,
_get_raw_file_path(date, site),
output_file,
site=site,
output_file=output_file,
)
elif prod[0] == "2":
if prod in ("2P04", "2P07", "2P08"):
Expand All @@ -76,10 +76,10 @@ def process_product(prod: str, date: datetime.date, site: str):
temp_file = None
hum_file = None
lev2_to_nc(
site,
prod,
_get_filename("1C01", date, site),
output_file,
site=site,
output_file=output_file,
temp_file=temp_file,
hum_file=hum_file,
)
Expand Down Expand Up @@ -166,5 +166,5 @@ def plot_product(prod: str, date, site: str):


def _get_raw_file_path(date_in: datetime.date, site: str) -> str:
_, params = read_yaml_config(site)
params = read_config(site, "params")
return os.path.join(params["data_in"], date_in.strftime("%Y/%m/%d/"))
7 changes: 2 additions & 5 deletions mwrpy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,8 @@ def get_processing_dates(args) -> tuple[str, str]:


def _get_filename(prod: str, date_in: datetime.date, site: str) -> str:
global_attributes, params = read_yaml_config(site)
global_attributes = read_config(site, "global_specs")
params = read_config(site, "params")
if np.char.isnumeric(prod[0]):
level = prod[0]
else:
Expand Down Expand Up @@ -592,7 +593,3 @@ def copy_global(
for attr in attributes:
if attr in source_attributes:
setattr(target, attr, source.getncattr(attr))


def read_yaml_config(site: str):
raise RuntimeError("This function is not implemented yet.")

0 comments on commit 319fee6

Please sign in to comment.