From 7b3976926f24782a00cfdcde33622bb4fced8fcb Mon Sep 17 00:00:00 2001 From: Christian Chwala Date: Wed, 26 May 2021 13:54:56 +0200 Subject: [PATCH] Fix example netcdf path (#84) * Moved NetCDF example data and adapted example notebook * removed ununsed csv.py module * bump version to 0.3.2 to have this as new conda version * update whats-new.rst --- docs/whats-new.rst | 13 +++ notebooks/Basic CML processing workflow.ipynb | 46 ++++++----- pycomlink/io/__init__.py | 2 - pycomlink/io/csv.py | 78 ------------------ .../io/{ => example_data}/example_cml_data.nc | Bin .../example_reference_data.nc | Bin setup.py | 4 +- 7 files changed, 39 insertions(+), 104 deletions(-) delete mode 100644 pycomlink/io/csv.py rename pycomlink/io/{ => example_data}/example_cml_data.nc (100%) rename pycomlink/io/{ => example_data}/example_reference_data.nc (100%) diff --git a/docs/whats-new.rst b/docs/whats-new.rst index 5ecdea4..e69d56b 100644 --- a/docs/whats-new.rst +++ b/docs/whats-new.rst @@ -2,6 +2,19 @@ What's New ********************** +v0.3.2 +------ + +* minor fix to include example NetCDF data in source distribution (by cchwala in PR #84) + + +v0.3.1 +------ + +* small update to how the dependencies are defined +* testing for Python verions 3.7, 3.8 and 3.9 + + v0.3.0 ------ diff --git a/notebooks/Basic CML processing workflow.ipynb b/notebooks/Basic CML processing workflow.ipynb index 540939c..0752e26 100644 --- a/notebooks/Basic CML processing workflow.ipynb +++ b/notebooks/Basic CML processing workflow.ipynb @@ -417,24 +417,24 @@ " polarization (cml_id, channel_id) object 'V' 'V' 'H' ... 'V' 'V' 'V'\n", "Data variables:\n", " rsl (channel_id, cml_id, time) float32 ...\n", - " tsl (channel_id, cml_id, time) float32 ...
    • rsl
      (channel_id, cml_id, time)
      float32
      ...
      [15840000 values with dtype=float32]
    • tsl
      (channel_id, cml_id, time)
      float32
      ...
      [15840000 values with dtype=float32]
  • " ], "text/plain": [ "\n", @@ -461,7 +461,9 @@ } ], "source": [ - "cmls = xr.open_dataset('../pycomlink/io/example_cml_data.nc')\n", + "data_path = pycml.io.examples.get_example_data_path()\n", + "\n", + "cmls = xr.open_dataset(data_path + '/example_cml_data.nc')\n", "cmls" ] }, @@ -846,12 +848,12 @@ " polarization (channel_id) object 'V' 'V'\n", "Data variables:\n", " rsl (channel_id, time) float32 -47.0 -47.0 ... -46.7 -47.0\n", - " tsl (channel_id, time) float32 13.0 12.0 12.0 ... 10.0 10.0
    • rsl
      (channel_id, time)
      float32
      ...
      array([[-47. , -47. , -46.7, ..., -47. , -46.7, -46.7],\n",
      +       "       [-46.7, -46.7, -47. , ..., -47. , -46.7, -47. ]], dtype=float32)
    • tsl
      (channel_id, time)
      float32
      ...
      array([[13., 12., 12., ..., 12., 12., 12.],\n",
      +       "       [ 9.,  9.,  9., ..., 10., 10., 10.]], dtype=float32)
  • " ], "text/plain": [ "\n", @@ -1181,7 +1183,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|██████████| 500/500 [00:30<00:00, 16.16it/s]\n" + "100%|██████████| 500/500 [00:48<00:00, 10.37it/s]\n" ] } ], @@ -1808,12 +1810,12 @@ " frequency (cml_id, channel_id) float64 2.491e+10 ... 2.598e+10\n", " polarization (cml_id, channel_id) object 'V' 'V' 'H' ... 'V' 'V' 'V'\n", "Data variables:\n", - " R (cml_id, channel_id, time) float64 0.0 0.0 0.0 ... 0.0 0.0
  • " ], "text/plain": [ "\n", diff --git a/pycomlink/io/__init__.py b/pycomlink/io/__init__.py index c68c4af..27e40be 100644 --- a/pycomlink/io/__init__.py +++ b/pycomlink/io/__init__.py @@ -1,4 +1,2 @@ from __future__ import absolute_import -from .csv import write_to_wasim_input_file - from . import examples diff --git a/pycomlink/io/csv.py b/pycomlink/io/csv.py deleted file mode 100644 index ebbeb55..0000000 --- a/pycomlink/io/csv.py +++ /dev/null @@ -1,78 +0,0 @@ -from builtins import str -import pandas as pd -import numpy as np -import pyproj - - -def write_to_wasim_input_file( - cml_list, - fn, - channel_name="channel_1", - source_projection=None, - target_projection=None, -): - """Write hourly CML rain rates to CSV file in WaSiM input file format - - Parameters - ---------- - - cml_list : list - List of Comlink objects - fn : str - Filename - channel_name : str, optional - Name of ComlinkChannel in Comlink object, defaults to 'channel_1' - source_projection : int, optional - EPSG projection number of coordinates in CML metadata - target_projection : int, optional - EPSG projection number of coordinates in CSV file - """ - - # Build DataFrame of rain rates for each CML - df = pd.DataFrame() - - for cml in cml_list: - df[cml.metadata["cml_id"]] = ( - cml.channels[channel_name].data.R.resample("H", label="right").mean() - ) - df["YYYY"] = df.index.year - df["MM"] = np.char.mod("%02d", df.index.month) - df["DD"] = np.char.mod("%02d", df.index.day) - df["HH"] = np.char.mod("%02d", df.index.hour) - df.loc[df["HH"] == "00", "HH"] = "24" - - # Reorder columns so that date columns come first - cols_time = ["YYYY", "MM", "DD", "HH"] - cols = cols_time + [ - col_name for col_name in df.columns if col_name not in cols_time - ] - df = df[cols] - - # Build DataFrame for coordinates and altitude (missing in current metadata) - df_coords = pd.DataFrame() - for date_str in ["YYYY", "MM", "DD", "HH"]: - df_coords[date_str] = 3 * [date_str] - for cml in cml_list: - if (source_projection is None) and (target_projection is None): - x, y = cml.get_center_lon_lat() - elif (source_projection is not None) and (target_projection is not None): - in_proj = pyproj.Proj(init="epsg:" + str(source_projection)) - out_proj = pyproj.Proj(init="epsg:" + str(target_projection)) - x, y = pyproj.transform(in_proj, out_proj, *cml.get_center_lon_lat()) - else: - raise ValueError( - "`source_projection` and `target_projection` " - "must both be either None or a EPSG string" - ) - altitude = -9999 - df_coords[cml.metadata["cml_id"]] = [altitude, x, y] - - # Write variable info to file - with open(fn, "w") as f: - f.write("Precipitation mm\n") - # Write coordinates to file - df_coords.to_csv(fn, mode="a", index=False, sep=" ", na_rep="-9999.0", header=False) - # Write rain rates to file - df.to_csv( - fn, mode="a", index=False, sep=" ", na_rep="-9999.0", float_format="%2.1f" - ) diff --git a/pycomlink/io/example_cml_data.nc b/pycomlink/io/example_data/example_cml_data.nc similarity index 100% rename from pycomlink/io/example_cml_data.nc rename to pycomlink/io/example_data/example_cml_data.nc diff --git a/pycomlink/io/example_reference_data.nc b/pycomlink/io/example_data/example_reference_data.nc similarity index 100% rename from pycomlink/io/example_reference_data.nc rename to pycomlink/io/example_data/example_reference_data.nc diff --git a/setup.py b/setup.py index 2fa7fca..9d22fc6 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ def read(fname): setup( name = "pycomlink", - version = "0.3.1", + version = "0.3.2", author = "Christian Chwala", author_email = "christian.chwala@kit.edu", description = ("Python tools for MW link data processing"), @@ -28,7 +28,7 @@ def read(fname): keywords = "microwave links precipitation radar", url = "https://github.com/pycomlink/pycomlink", download_url = ( - "https://github.com/pycomlink/pycomlink/archive/0.3.1.tar.gz"), + "https://github.com/pycomlink/pycomlink/archive/0.3.2.tar.gz"), packages=find_packages(exclude=['test']), include_package_data=True, long_description=read('README.md'),