Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions .github/workflows/run-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ on:
schedule:
- cron: '0 2 * * *' # Runs at 2:00 AM UTC every day

env:
ARM_USERNAME: ${{ secrets.ARM_USERNAME }}
ARM_PASSWORD: ${{ secrets.ARM_PASSWORD }}

jobs:
build:
name: ${{ matrix.os }}-${{ matrix.python-version }}
if: github.repository == 'openradar/PyDDA'
if: github.repository == 'ARM-Development/radclss'
runs-on: ${{ matrix.os }}-latest
defaults:
run:
Expand All @@ -33,24 +37,21 @@ jobs:
uses: mamba-org/setup-micromamba@v2.0.6
with:
create-args: python=${{ matrix.python-version }}
environment-file: continuous_integration/environment-actions-${{ matrix.python-version }}.yml
environment-file: continuous-integration/environment-actions.yml
micromamba-version: '2.0.0-0'
environment-name: pydda-env
environment-name: radclss_env
cache-downloads: false

- name: Install RadCLss
shell: bash -l {0}
run: |
python -m pip install -e . --no-deps --force-reinstall

- name: Lint with flake8
- name: Lint with ruff
shell: bash -l {0}
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
pip install ruff
ruff check .

- name: Test with pytest
shell: bash -l {0}
Expand Down
1 change: 1 addition & 0 deletions continuous-integration/environment-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ channels:
dependencies:
- arm_pyart
- pip
- act-atmos
- xradar
- pytest
- pytest-mpl
Expand Down
72 changes: 46 additions & 26 deletions examples/bnf_example.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,62 @@
import radclss
import glob
import xradar as xd
import xarray as xr
import matplotlib.pyplot as plt

from dask.distributed import Client, LocalCluster


def main():
date = '20250619'
radar_files = glob.glob(f'/Volumes/Untitled/bnf/bnfcsapr2cmacS3.c1/*{date}*.nc')
volumes = {'date': date,
'radar': radar_files[0:2], # Limit to first 2 files for testing
'sonde': glob.glob(f'/Volumes/Untitled/bnf/in_situ/bnfsondewnpnM1.b1/*{date}*.cdf'),
'vd_M1': glob.glob(f'/Volumes/Untitled/bnf/in_situ/bnfvdisquantsM1.c1/*{date}*.nc'),
'met_M1': glob.glob(f'/Volumes/Untitled/bnf/in_situ/bnfmetM1.b1/*{date}*'),
'met_S20': glob.glob(f'/Volumes/Untitled/bnf/in_situ/bnfmetS20.b1/*{date}*'),
'met_S30': glob.glob(f'/Volumes/Untitled/bnf/in_situ/bnfmetS30.b1/*{date}*'),
'met_S40': glob.glob(f'/Volumes/Untitled/bnf/in_situ/bnfmetS40.b1/*{date}*'),
'wxt_S13': glob.glob(f'/Volumes/Untitled/bnf/in_situ/bnfmetwxtS13.b1/*{date}*.nc'),
'pluvio_M1': glob.glob(f'/Volumes/Untitled/bnf/in_situ/bnfwbpluvio2M1.a1/*{date}*.nc'),
'ld_M1': glob.glob(f'/Volumes/Untitled/bnf/in_situ/bnfldquantsM1.c1/*{date}*.nc'),
'ld_S30': glob.glob(f'/Volumes/Untitled/bnf/in_situ/bnfldquantsS30.c1/*{date}*.nc')}
date = "20250619"
radar_files = glob.glob(f"/Volumes/Untitled/bnf/bnfcsapr2cmacS3.c1/*{date}*.nc")
volumes = {
"date": date,
"radar": radar_files[0:2], # Limit to first 2 files for testing
"sonde": glob.glob(
f"/Volumes/Untitled/bnf/in_situ/bnfsondewnpnM1.b1/*{date}*.cdf"
),
"vd_M1": glob.glob(
f"/Volumes/Untitled/bnf/in_situ/bnfvdisquantsM1.c1/*{date}*.nc"
),
"met_M1": glob.glob(f"/Volumes/Untitled/bnf/in_situ/bnfmetM1.b1/*{date}*"),
"met_S20": glob.glob(f"/Volumes/Untitled/bnf/in_situ/bnfmetS20.b1/*{date}*"),
"met_S30": glob.glob(f"/Volumes/Untitled/bnf/in_situ/bnfmetS30.b1/*{date}*"),
"met_S40": glob.glob(f"/Volumes/Untitled/bnf/in_situ/bnfmetS40.b1/*{date}*"),
"wxt_S13": glob.glob(
f"/Volumes/Untitled/bnf/in_situ/bnfmetwxtS13.b1/*{date}*.nc"
),
"pluvio_M1": glob.glob(
f"/Volumes/Untitled/bnf/in_situ/bnfwbpluvio2M1.a1/*{date}*.nc"
),
"ld_M1": glob.glob(
f"/Volumes/Untitled/bnf/in_situ/bnfldquantsM1.c1/*{date}*.nc"
),
"ld_S30": glob.glob(
f"/Volumes/Untitled/bnf/in_situ/bnfldquantsS30.c1/*{date}*.nc"
),
}

input_site_dict = {'M1': (34.34525, -87.33842, 293),
'S4': (34.46451, -87.23598, 197),
'S20': (34.65401, -87.29264, 178),
'S30': (34.38501, -86.92757, 183),
'S40': (34.17932, -87.45349, 236),
'S13': (34.343889, -87.350556, 286)}
with Client(LocalCluster(n_workers=2, threads_per_worker=1)) as client:
my_columns = radclss.core.radclss(volumes, input_site_dict, serial=False, verbose=True)
radclss.io.write_radclss_output(my_columns, 'radclss_example.nc', 'csapr2radclss.c2')
input_site_dict = {
"M1": (34.34525, -87.33842, 293),
"S4": (34.46451, -87.23598, 197),
"S20": (34.65401, -87.29264, 178),
"S30": (34.38501, -86.92757, 183),
"S40": (34.17932, -87.45349, 236),
"S13": (34.343889, -87.350556, 286),
}
with Client(LocalCluster(n_workers=2, threads_per_worker=1)) as client: # noqa
my_columns = radclss.core.radclss(
volumes, input_site_dict, serial=False, verbose=True
)
radclss.io.write_radclss_output(
my_columns, "radclss_example.nc", "csapr2radclss.c2"
)

for vars in my_columns.data_vars:
print(vars, my_columns[vars].dtype)
fig, ax = radclss.vis.create_radclss_columns('radclss_example.nc')
fig, ax = radclss.vis.create_radclss_columns("radclss_example.nc")
print(fig)
plt.show()


if __name__ == "__main__":
main()
10 changes: 5 additions & 5 deletions radclss/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
====================================================
"""

from . import config
from . import core
from . import util
from . import vis
from . import io
from . import config # noqa
from . import core # noqa
from . import util # noqa
from . import vis # noqa
from . import io # noqa
22 changes: 18 additions & 4 deletions radclss/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
from .default_config import DEFAULT_DISCARD_VAR, set_discarded_variables
from .output_config import set_output_site, set_output_facility, set_output_platform, set_output_level
from .output_config import set_output_gate_time_attrs, set_output_time_offset_attrs, get_output_config
from .output_config import set_output_alt_attrs, set_output_lat_attrs, set_output_lon_attrs, set_output_station_attrs
from .default_config import DEFAULT_DISCARD_VAR, set_discarded_variables # noqa
from .output_config import (
set_output_site, # noqa
set_output_facility, # noqa
set_output_platform, # noqa
set_output_level, # noqa
) # noqa
from .output_config import (
set_output_gate_time_attrs, # noqa
set_output_time_offset_attrs, # noqa
get_output_config, # noqa
) # noqa
from .output_config import (
set_output_alt_attrs, # noqa
set_output_lat_attrs, # noqa
set_output_lon_attrs, # noqa
set_output_station_attrs, # noqa
) # noqa
72 changes: 49 additions & 23 deletions radclss/config/output_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,35 @@
OUTPUT_FACILITY = "S2"
OUTPUT_PLATFORM = "csapr2radclss"
OUTPUT_LEVEL = "c2"
OUTPUT_GATE_TIME_ATTRS = {'long_name': ('Time in Seconds that Cooresponds to the Start'
+ " of each Individual Radar Volume Scan before"
+ " Concatenation"),
'description': 'Time in Seconds that Cooresponds to the Minimum Height Gate'}
OUTPUT_TIME_OFFSET_ATTRS = dict(long_name=("Time in Seconds Since Midnight"),
description=("Time in Seconds Since Midnight that Cooresponds"
+ "to the Center of Each Height Gate"
+ "Above the Target Location "))
OUTPUT_STATION_ATTRS = dict(long_name="Bankhead National Forest AMF-3 In-Situ Ground Observation Station Identifers")
OUTPUT_LAT_ATTRS = dict(long_name=f'Latitude of BNF AMF-3 Ground Observation Site', units='Degrees North')
OUTPUT_LON_ATTRS = dict(long_name='Longitude of BNF AMF-3 Ground Observation Site', units='Degrees East')
OUTPUT_ALT_ATTRS = dict(long_name="Altitude above mean sea level for each station", units="m")
OUTPUT_GATE_TIME_ATTRS = {
"long_name": (
"Time in Seconds that Cooresponds to the Start"
+ " of each Individual Radar Volume Scan before"
+ " Concatenation"
),
"description": "Time in Seconds that Cooresponds to the Minimum Height Gate",
}
OUTPUT_TIME_OFFSET_ATTRS = dict(
long_name=("Time in Seconds Since Midnight"),
description=(
"Time in Seconds Since Midnight that Cooresponds"
+ "to the Center of Each Height Gate"
+ "Above the Target Location "
),
)
OUTPUT_STATION_ATTRS = dict(
long_name="Bankhead National Forest AMF-3 In-Situ Ground Observation Station Identifers"
)
OUTPUT_LAT_ATTRS = dict(
long_name="Latitude of BNF AMF-3 Ground Observation Site", units="Degrees North"
)
OUTPUT_LON_ATTRS = dict(
long_name="Longitude of BNF AMF-3 Ground Observation Site", units="Degrees East"
)
OUTPUT_ALT_ATTRS = dict(
long_name="Altitude above mean sea level for each station", units="m"
)


def set_output_site(site):
"""
Expand All @@ -27,6 +44,7 @@ def set_output_site(site):
global OUTPUT_SITE
OUTPUT_SITE = site


def set_output_facility(facility):
"""
Set the output facility for RadCLss files.
Expand All @@ -39,6 +57,7 @@ def set_output_facility(facility):
global OUTPUT_FACILITY
OUTPUT_FACILITY = facility


def set_output_platform(platform):
"""
Set the output platform for RadCLss files.
Expand All @@ -51,6 +70,7 @@ def set_output_platform(platform):
global OUTPUT_PLATFORM
OUTPUT_PLATFORM = platform


def set_output_level(level):
"""
Set the output level for RadCLss files.
Expand All @@ -63,21 +83,23 @@ def set_output_level(level):
global OUTPUT_LEVEL
OUTPUT_LEVEL = level


def set_output_gate_time_attrs(attrs):
"""
Set the attributes for the gate_time variable.
Set the attributes for the gate_time variable.

Parameters
----------
attrs : dict
Dictionary of attributes for gate_time.
"""
global OUTPUT_GATE_TIME_ATTRS
OUTPUT_GATE_TIME_ATTRS = attrs
OUTPUT_GATE_TIME_ATTRS = attrs


def set_output_time_offset_attrs(attrs):
"""
Set the attributes for the time_offset variable.
Set the attributes for the time_offset variable.

Parameters
----------
Expand All @@ -87,17 +109,19 @@ def set_output_time_offset_attrs(attrs):
global OUTPUT_TIME_OFFSET_ATTRS
OUTPUT_TIME_OFFSET_ATTRS = attrs


def set_output_station_attrs(attrs):
"""
Set the attributes for the station variable.

Parameters
----------
attrs : dict
Dictionary of attributes for station.
"""
global OUTPUT_STATION_ATTRS
OUTPUT_STATION_ATTRS = attrs
OUTPUT_STATION_ATTRS = attrs


def set_output_lat_attrs(attrs):
"""
Expand All @@ -111,17 +135,19 @@ def set_output_lat_attrs(attrs):
global OUTPUT_LAT_ATTRS
OUTPUT_LAT_ATTRS = attrs


def set_output_lon_attrs(attrs):
"""
Set the attributes for the lon variable.

Parameters
----------
attrs : dict
Dictionary of attributes for lon.
"""
global OUTPUT_LON_ATTRS
OUTPUT_LON_ATTRS = attrs
OUTPUT_LON_ATTRS = attrs


def set_output_alt_attrs(attrs):
"""
Expand All @@ -133,7 +159,8 @@ def set_output_alt_attrs(attrs):
Dictionary of attributes for alt.
"""
global OUTPUT_ALT_ATTRS
OUTPUT_ALT_ATTRS = attrs
OUTPUT_ALT_ATTRS = attrs


def get_output_config():
"""
Expand All @@ -154,6 +181,5 @@ def get_output_config():
"station_attrs": OUTPUT_STATION_ATTRS,
"lat_attrs": OUTPUT_LAT_ATTRS,
"lon_attrs": OUTPUT_LON_ATTRS,
"alt_attrs": OUTPUT_ALT_ATTRS
}

"alt_attrs": OUTPUT_ALT_ATTRS,
}
2 changes: 1 addition & 1 deletion radclss/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .write import write_radclss_output
from .write import write_radclss_output # noqa
Loading
Loading