Skip to content

Commit

Permalink
Merge pull request #41 from NOAA-CEFI-Portal/develop
Browse files Browse the repository at this point in the history
Develop mhw merge to main branch
  • Loading branch information
chiaweh2 authored Sep 4, 2024
2 parents 3278746 + fb0b39c commit 404f882
Show file tree
Hide file tree
Showing 16 changed files with 2,846 additions and 52 deletions.
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ dependencies:
- xesmf
- pytest
- beautifulsoup4
- matplotlib
31 changes: 12 additions & 19 deletions mom6/mom6_module/deprecated/mom6_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,19 @@
import xarray as xr
from scipy.stats import norm as normal
from mom6 import DATA_PATH
from mom6.mom6_module.mom6_types import RegionalOptions,GridOptions,DataTypeOptions,DataSourceOptions

warnings.simplefilter("ignore")
xr.set_options(keep_attrs=True)


# typing
RegionalOptions = Literal[
'MAB','GOM','SS','GB','SS_LME','NEUS_LME','SEUS_LME',
'GOMEX','GSL','NGOMEX','SGOMEX','Antilles','Floridian'
]



class OpenDapStore:
"""class to handle the OPeNDAP request
"""
def __init__(
self,
grid : Literal['raw','regrid'] = 'raw',
data_type : Literal['forecast','historical'] = 'historical'
grid : GridOptions = 'raw',
data_type : DataTypeOptions = 'historical'
) -> None:
"""
input for the class to get the opendap data
Expand Down Expand Up @@ -136,8 +129,8 @@ def __init__(
iyear : int,
imonth : int,
var : str,
grid : Literal['raw','regrid'] = 'raw',
source : Literal['local','opendap'] = 'local'
grid : GridOptions = 'raw',
source : DataSourceOptions = 'local'
) -> None:
"""
input for the class to get the individual forecast
Expand Down Expand Up @@ -222,8 +215,8 @@ def get_mom6(self) -> xr.Dataset:
@staticmethod
def get_mom6_all(
var : str,
grid : Literal['raw','regrid'] = 'raw',
source : Literal['local','opendap'] = 'local'
grid : GridOptions = 'raw',
source : DataSourceOptions = 'local'
) -> xr.Dataset:
"""
Return the mom6 all rawgrid/regridded hindcast/forecast field
Expand Down Expand Up @@ -586,8 +579,8 @@ def __init__(
year : int,
month : int,
day : int = 1,
grid : Literal['raw','regrid'] = 'raw',
source : Literal['local','opendap'] = 'local'
grid : GridOptions = 'raw',
source : DataSourceOptions = 'local'
) -> None:
"""
input for getting the historical run data
Expand Down Expand Up @@ -672,8 +665,8 @@ def get_mom6(self) -> xr.Dataset:
@staticmethod
def get_mom6_all(
var : str,
grid : Literal['raw','regrid'] = 'raw',
source : Literal['local','opendap'] = 'local'
grid : GridOptions = 'raw',
source : DataSourceOptions = 'local'
) -> xr.Dataset:
"""
Return the mom6 all rawgrid/regridded historical run field
Expand Down Expand Up @@ -774,7 +767,7 @@ def get_mom6_grid() -> xr.Dataset:
@staticmethod
def get_mom6_mask(
mask : Literal['wet','wet_c','wet_u','wet_v'] = 'wet',
grid : Literal['raw','regrid'] = 'raw'
grid : GridOptions = 'raw'
) -> xr.DataArray:
"""
The function is designed to export the various mask provided
Expand Down
26 changes: 10 additions & 16 deletions mom6/mom6_module/mom6_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,21 @@
import numpy as np
import xarray as xr
from mom6 import DATA_PATH
from mom6.mom6_module.mom6_types import ModelRegionOptions,GridOptions,DataTypeOptions,DataSourceOptions

warnings.simplefilter("ignore")
xr.set_options(keep_attrs=True)


# typing
RegionalOptions = Literal[
'MAB','GOM','SS','GB','SS_LME','NEUS_LME','SEUS_LME',
'GOMEX','GSL','NGOMEX','SGOMEX','Antilles','Floridian'
]



class OpenDapStore:
"""class to handle the OPeNDAP request
"""
def __init__(
self,
region : Literal['northwest_atlantic'] = 'northwest_atlantic',
grid : Literal['raw','regrid'] = 'raw',
data_type : Literal['forecast','historical'] = 'historical'
region : ModelRegionOptions = 'northwest_atlantic',
grid : GridOptions = 'raw',
data_type : DataTypeOptions = 'historical'
) -> None:
"""
input for the class to get the opendap data
Expand Down Expand Up @@ -136,8 +130,8 @@ def __init__(
data_relative_dir : str = None,
static_relative_dir : str = None,
tercile_relative_dir : str = None,
grid : Literal['raw','regrid'] = 'raw',
source : Literal['local','opendap'] = 'local',
grid : GridOptions = 'raw',
source : DataSourceOptions = 'local',
) -> None:
"""
input for the class to get the forecast data
Expand Down Expand Up @@ -219,7 +213,7 @@ def get_all(self) -> xr.Dataset:
chunks=io_chunk
).sortby('init')
ds = xr.merge([ds_static,ds])
# ds = ds.isel(init=slice(1,None)) # exclude the 1980 empty field due to merge
ds = ds.drop_vars(['time']) # a result of merge of ds_static

# test if accident read regrid file
try:
Expand Down Expand Up @@ -324,7 +318,7 @@ def get_tercile(
chunks=io_chunk
).sortby('init')
ds = xr.merge([ds_static,ds])
# ds = ds.isel(init=slice(1,None)) # exclude the 1980 empty field due to merge
ds = ds.drop_vars(['time']) # a result of merge of ds_static

# test if accident read regrid file
try:
Expand Down Expand Up @@ -497,8 +491,8 @@ def __init__(
var : str,
data_relative_dir : str = None,
static_relative_dir : str = None,
grid : Literal['raw','regrid'] = 'raw',
source : Literal['local','opendap'] = 'local',
grid : GridOptions = 'raw',
source : DataSourceOptions = 'local',
) -> None:
"""
input for getting the historical run data
Expand Down
Loading

0 comments on commit 404f882

Please sign in to comment.