Skip to content

Commit

Permalink
Merge pull request #37 from NOAA-CEFI-Portal/hotfix-regiondir
Browse files Browse the repository at this point in the history
Hotfix for data path
  • Loading branch information
chiaweh2 authored Jun 21, 2024
2 parents 550cd86 + 312938e commit 1617505
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gha_pytest_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: regional_mom6.yml
environment-file: environment.yml
init-shell: bash

- name: Setup package config file
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gha_pytest_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-file: regional_mom6.yml
environment-file: environment.yml
init-shell: bash

- name: Setup package config file
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ To use the module in the package at this stage
}
```
current setup assuming the data directory structure is fixed (flexibility need to be considered)
current setup assuming the data directory structure is fixed (i.e. the historical run or forecast data subdirectory (ex: hist_run and forecast) need to be under this data_path )
4 changes: 2 additions & 2 deletions regional_mom6.yml → environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: regional_mom6
name: regional-mom6
channels:
- conda-forge
dependencies:
Expand All @@ -9,4 +9,4 @@ dependencies:
- xarray
- xesmf
- pytest
- beautifulsoup4
- beautifulsoup4
8 changes: 6 additions & 2 deletions mom6/mom6_module/mom6_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class OpenDapStore:
"""
def __init__(
self,
region : Literal['northwest_atlantic'] = 'northwest_atlantic',
grid : Literal['raw','regrid'] = 'raw',
data_type : Literal['forecast','historical'] = 'historical'
) -> None:
Expand All @@ -53,6 +54,7 @@ def __init__(
to calculate the indexes, by default 'historical'
"""
self.region = region
self.grid = grid
self.data_type = data_type

Expand Down Expand Up @@ -86,13 +88,15 @@ def get_catalog(self)-> list:
elif self.grid == 'regrid' :
gridtype = 'regrid/'

regiontype = self.region

catalog_url = (
'https://psl.noaa.gov/thredds/catalog/'+
f'Projects/CEFI/regional_mom6/{datatype}/{gridtype}'
f'Projects/CEFI/regional_mom6/{regiontype}/{datatype}/{gridtype}'
)
opendap_url = (
'https://psl.noaa.gov/thredds/dodsC/'+
f'Projects/CEFI/regional_mom6/{datatype}/{gridtype}'
f'Projects/CEFI/regional_mom6/{regiontype}/{datatype}/{gridtype}'
)

# Send a GET request to the URL
Expand Down
9 changes: 8 additions & 1 deletion mom6/notebook/nechannel_index.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
"""
This is a pytest setting file to have the option of
pytesting under different location/platform
To do pytest on the local machine
`pytest` (will do the opendap option below)
`pytest --location opendap` (testing mock index calculation)
`pytest --location local` (testing real index calculation)
"""
import pytest

def pytest_addoption(parser):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_mom6_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_OpenDapStore():
"""Test OpenDap Connection
"""

opendap_raw = mom6_io.OpenDapStore('raw','historical')
opendap_raw = mom6_io.OpenDapStore(grid='raw',data_type='historical',region='northwest_atlantic')
test_url = opendap_raw.get_catalog()[0]
try:
ds = xr.open_dataset(test_url)
Expand All @@ -21,7 +21,7 @@ def test_OpenDapStore():
pytest.fail('OSError is raised OPeNDAP url not working')


opendap_regrid = mom6_io.OpenDapStore('regrid','historical')
opendap_regrid = mom6_io.OpenDapStore(grid='regrid',data_type='historical',region='northwest_atlantic')
test_url = opendap_regrid.get_catalog()[0]
try:
ds = xr.open_dataset(test_url)
Expand All @@ -34,7 +34,7 @@ def test_OpenDapStore():
def test_MOM6Forecast(location):
"""Test the forecast IO
only available local
currently only available local
Parameters
----------
Expand Down

0 comments on commit 1617505

Please sign in to comment.