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
44 changes: 40 additions & 4 deletions dnora/read/current/metno.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from dnora.read.depreciation_decorator import deprecated_class_call


def get_norkyst800_urls(folder: str, filename: str, file_times: list[str], **kwargs):
def get_norkyst800v2_urls(folder: str, filename: str, file_times: list[str], **kwargs):
"""This is passed to the read_ds_list. We need it because the folder and filename that makes up th URL changes is time"""
urls = []

Expand All @@ -38,8 +38,8 @@ def get_norkyst800_urls(folder: str, filename: str, file_times: list[str], **kwa


@deprecated_class_call("MET Norway's", "metno", "current")
class NorKyst800(ProductReader):
"""Reads ocean_current data of the NorKyst800 archieve directly from MET Norways servers.
class NorKyst800v2(ProductReader):
"""Reads ocean_current data of the NorKyst800v2 archieve directly from MET Norways servers.

NorKyst-800 (Norwegian Coast 800m) is a numerical, high-resolution, ocean modelling
system covering the Norwegian Coast.
Expand All @@ -60,7 +60,7 @@ class NorKyst800(ProductReader):
),
data_vars=["u", "v"],
default_data_source=DataSource.REMOTE,
url_function=get_norkyst800_urls,
url_function=get_norkyst800v2_urls,
ds_aliases={"u": gp.ocean.XCurrent, "v": gp.ocean.YCurrent},
ds_pre_processor=lambda ds: (ds.isel(depth=0), {}),
)
Expand All @@ -73,6 +73,42 @@ class NorKyst800(ProductReader):
def post_processing(self):
return FillNaNs(0)

@deprecated_class_call("MET Norway's", "metno", "current")
class NorKyst800v3(ProductReader):
"""Reads ocean_current data of the NorKyst800v3 hindcast archieve directly from MET Norways servers.

NorKyst-800 (Norwegian Coast 800m) is a numerical, high-resolution, ocean modelling
system covering the Norwegian Coast.

Albretsen, J., Sperrevik, A.K., Staalstrøm, A., Sandvik, A.D., Vikebø, F., Asplin, L., 2011.
NorKyst-800 Rapport nr. 1: Brukermanual og tekniske beskrivelser. NorKyst-800 Report
No. 1: User Manual and technical descriptions.
"""

product_configuration = ProductConfiguration(
filename="norkyst800-%Y%m%d.nc",
default_folders={
DataSource.REMOTE: "https://thredds.met.no/thredds/dodsC/romshindcast/norkyst_v3/zdepth/%Y/%m",
},
ds_creator_function=partial(
ds_fimex_read,
resolution_in_km=0.8,
),
data_vars=["u_eastward", "v_northward"],
default_data_source=DataSource.REMOTE,
ds_aliases={"u_eastward": gp.ocean.XCurrent, "v_northward": gp.ocean.YCurrent},
ds_pre_processor=lambda ds: (ds.isel(depth=0), {}),
)

file_structure = FileStructure(
stride=24,
hours_per_file=24,
)

def post_processing(self):
return FillNaNs(0)



@deprecated_class_call("MET Norway's", "metno", "current")
class NorFjords160(ProductReader):
Expand Down
14 changes: 12 additions & 2 deletions tests/test_readers/test_remote_current_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def cleanup():
@pytest.mark.remote
def test_norkyst800(grid, timevec):
model = dn.modelrun.ModelRun(grid, year=2022, month=4, day=1)
model.import_current(dn.read.current.metno.NorKyst800(), program="pyfimex")
model.import_current(dn.read.current.metno.NorKyst800v2(), program="pyfimex")

assert np.all(model.current().time() == timevec)
assert model.current().u(strict=True) is not None
Expand All @@ -49,12 +49,22 @@ def test_norkyst800(grid, timevec):
@pytest.mark.remote
def test_norkyst800_2017(grid, timevec2017):
model = dn.modelrun.ModelRun(grid, year=2017, month=4, day=1)
model.import_current(dn.read.current.metno.NorKyst800(), program="pyfimex")
model.import_current(dn.read.current.metno.NorKyst800v2(), program="pyfimex")

assert np.all(model.current().time() == timevec2017)
assert model.current().u(strict=True) is not None
assert model.current().v(strict=True) is not None

@pytest.mark.remote
def test_norkyst800v3(grid, timevec):
model = dn.modelrun.ModelRun(grid, year=2022, month=4, day=1)
model.import_current(dn.read.current.metno.NorKyst800v3(), program="pyfimex")

assert np.all(model.current().time() == timevec)
assert model.current().u(strict=True) is not None
assert model.current().v(strict=True) is not None


@pytest.mark.internal
@pytest.mark.remote
def test_norfjords160(grid160, timevec):
Expand Down
Loading