From 9fcf2cea806fdf827527e1312dab78545076079a Mon Sep 17 00:00:00 2001 From: Daniel Wolfensberger Date: Wed, 12 Feb 2025 10:30:10 +0100 Subject: [PATCH] ENH: better layout in products rst overview --- ci/parse_pyrad_products.py | 20 ++++++------ .../pyrad/prod/process_grid_products.py | 31 +++++++++---------- .../pyrad/prod/process_monitoring_products.py | 4 +-- src/pyrad_proc/pyrad/prod/process_product.py | 3 +- 4 files changed, 26 insertions(+), 32 deletions(-) diff --git a/ci/parse_pyrad_products.py b/ci/parse_pyrad_products.py index e4df6c1e..0390dd0b 100644 --- a/ci/parse_pyrad_products.py +++ b/ci/parse_pyrad_products.py @@ -65,7 +65,9 @@ def dict_to_restructured_text(yaml_data): rst_output.append('""""""""""""""""""""""""""""""') rst_output.append("description") rst_output.append( - " " + prodinfo["description"] + f'\n `[Source] <{prodinfo["link"]}>`_' + " | " + + prodinfo["description"].replace("###", "\n |") + + f'\n `[Source] <{prodinfo["link"]}>`_' ) params = parameters_to_dict(prodinfo["parameters"]) if len(params): @@ -96,7 +98,7 @@ def process_file(filepath): # clear buffer try: all_products[function][product]["description"] = " ".join( - descr.replace("\n", "").split() + descr.split() ) except (KeyError, UnboundLocalError, TypeError): pass @@ -124,25 +126,23 @@ def process_file(filepath): try: if product in all_products[function]: all_products[function][product]["description"] = " ".join( - descr.replace("\n", "").split() + descr.split() ) except TypeError: pass product = match[0].replace("'", "").split(":")[0].strip() - descr = line.split(":")[1].strip() + descr = line.split(":")[1].strip() + "###" all_products[function][product] = {} all_products[function][product]["parameters"] = "" continue if "User defined parameters" in line: - all_products[function][product]["description"] = " ".join( - descr.replace("\n", "").split() - ) + all_products[function][product]["description"] = " ".join(descr.split()) reading_params = True reading_title = False continue if reading_title: - descr += line + descr += line + "###" if reading_params and product: all_products[function][product]["parameters"] += " " + line if ('prdcfg["type"]' in line or "prdcfg['type']" in line) and "==" in line: @@ -153,9 +153,7 @@ def process_file(filepath): ) if reading_title: - all_products[function][product]["description"] = " ".join( - descr.replace("\n", "").split() - ) + all_products[function][product]["description"] = " ".join(descr.split()) return all_products diff --git a/src/pyrad_proc/pyrad/prod/process_grid_products.py b/src/pyrad_proc/pyrad/prod/process_grid_products.py index d882f124..622a329d 100755 --- a/src/pyrad_proc/pyrad/prod/process_grid_products.py +++ b/src/pyrad_proc/pyrad/prod/process_grid_products.py @@ -161,7 +161,7 @@ def generate_grid_products(dataset, prdcfg): 'CROSS_SECTION': Plots a cross-section of gridded data User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset coord1, coord2: dict The two lat-lon coordinates marking the limits. They have the keywords 'lat' and 'lon' [degree]. The altitude limits @@ -170,7 +170,7 @@ def generate_grid_products(dataset, prdcfg): 'HISTOGRAM': Computes a histogram of the radar volum data User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset step: float or None the data quantization step. If none it will be obtained from the Py-ART configuration file @@ -185,7 +185,7 @@ def generate_grid_products(dataset, prdcfg): constant latitude. User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset lon, lat: floats The starting point of the cross-section. The ending point is defined by the parameters in 'xsecImageConfig' in the @@ -194,7 +194,7 @@ def generate_grid_products(dataset, prdcfg): constant longitude. User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset lon, lat: floats The starting point of the cross-section. The ending point is defined by the parameters in 'xsecImageConfig' in the @@ -210,7 +210,7 @@ def generate_grid_products(dataset, prdcfg): 'SAVEVOL': Saves on field of a gridded data object in a netcdf file. User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset file_type: str The type of file used to save the data. Can be 'nc' or 'h5'. Default 'nc' @@ -232,14 +232,14 @@ def generate_grid_products(dataset, prdcfg): a file. User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset stat: str The statistic used. Can be mean, median, min, max 'SURFACE_RAW': Plots a surface image of gridded data without projecting it into a map User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset level: int The altitude level to plot. The rest of the parameters are defined by the parameters in 'ppiImageConfig' and @@ -247,7 +247,7 @@ def generate_grid_products(dataset, prdcfg): 'SURFACE_IMAGE': Plots a surface image of gridded data. User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset level: int The altitude level to plot. The rest of the parameters are defined by the parameters in 'ppiImageConfig' and @@ -255,7 +255,7 @@ def generate_grid_products(dataset, prdcfg): 'SURFACE_CONTOUR': Plots a surface image of contour gridded data. User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset level: int The altitude level to plot. The rest of the parameters are defined by the parameters in 'ppiImageConfig' and @@ -274,7 +274,7 @@ def generate_grid_products(dataset, prdcfg): Plots a surface image of gridded data with a contour overplotted. User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset level: int The altitude level to plot. The rest of the parameters are defined by the parameters in 'ppiImageConfig' and @@ -293,7 +293,7 @@ def generate_grid_products(dataset, prdcfg): Plots on the same surface two images, one on top of the other. User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset level: int The altitude level to plot. The rest of the parameters are defined by the parameters in 'ppiImageConfig' and @@ -309,7 +309,7 @@ def generate_grid_products(dataset, prdcfg): The pyDDA package is required User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset level: int The altitude level to plot. The rest of the parameters are defined by the parameters in 'ppiImageConfig' and @@ -347,7 +347,7 @@ def generate_grid_products(dataset, prdcfg): The pyDDA package is required User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset level: int The longitude level to plot. The rest of the parameters are defined by the parameters in 'xsecImageConfig' in the 'loc' @@ -385,7 +385,7 @@ def generate_grid_products(dataset, prdcfg): The pyDDA package is required User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset level: int The latitude level to plot. The rest of the parameters are defined by the parameters in 'xsecImageConfig' in the 'loc' @@ -1153,7 +1153,6 @@ def generate_grid_products(dataset, prdcfg): return fname if prdcfg["type"] == "DDA_MAP": - display_type = prdcfg.get("display_type", "quiver") if display_type not in ["quiver", "barbs", "streamline"]: warn("Invalid display_type, must be " + '"streamline", "quiver" or "barbs"') @@ -1214,7 +1213,6 @@ def generate_grid_products(dataset, prdcfg): print("----- save to " + " ".join(fname_list)) if prdcfg["type"] == "DDA_LONGITUDE_SLICE": - display_type = prdcfg.get("display_type", "quiver") if display_type not in ["quiver", "barbs", "streamline"]: warn("Invalid display_type, must be " + '"streamline", "quiver" or "barbs"') @@ -1287,7 +1285,6 @@ def generate_grid_products(dataset, prdcfg): print("----- save to " + " ".join(fname_list)) if prdcfg["type"] == "DDA_LATITUDE_SLICE": - display_type = prdcfg.get("display_type", "quiver") if display_type not in ["quiver", "barbs", "streamline"]: warn("Invalid display_type, must be " + '"streamline", "quiver" or "barbs"') diff --git a/src/pyrad_proc/pyrad/prod/process_monitoring_products.py b/src/pyrad_proc/pyrad/prod/process_monitoring_products.py index cf9c9d32..f2c750ee 100755 --- a/src/pyrad_proc/pyrad/prod/process_monitoring_products.py +++ b/src/pyrad_proc/pyrad/prod/process_monitoring_products.py @@ -48,7 +48,7 @@ def generate_monitoring_products(dataset, prdcfg): are also plot on the same figure User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset anglenr: int The elevation angle number to plot quantiles: list of floats @@ -62,7 +62,7 @@ def generate_monitoring_products(dataset, prdcfg): quantiles stored in a csv file. User defined parameters: voltype: str - name of the pyrad variable to use, it must be available in the dataset in the dataset + name of the pyrad variable to use, it must be available in the dataset quantiles: list of 3 floats the quantiles to compute. Default 25., 50., 75. ref_value: float diff --git a/src/pyrad_proc/pyrad/prod/process_product.py b/src/pyrad_proc/pyrad/prod/process_product.py index ad48dfb3..f27b5dd7 100755 --- a/src/pyrad_proc/pyrad/prod/process_product.py +++ b/src/pyrad_proc/pyrad/prod/process_product.py @@ -413,8 +413,7 @@ def generate_sun_hits_products(dataset, prdcfg): User defined parameters: add_date_in_fname: Bool If true the year is added in the csv file name - 'WRITE_SUNSCAN': Writes the sunscan parameters in a csv file. The written data has the following - columns + 'WRITE_SUNSCAN': Writes the sunscan parameters in a csv file. The written data has the following columns "sun_az": [deg] Azimuth sun position, "sun_el": [deg] Elevation sun position, "noise_pwr": [dBm] Noise power",