Skip to content

Commit

Permalink
Merge pull request #62 from SorooshMani-NOAA/enhance/besttrack
Browse files Browse the repository at this point in the history
Add `model_type_pahm` parameter support
  • Loading branch information
cuill authored Mar 30, 2023
2 parents fb4d23b + 29f7533 commit 3474ce2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyschism/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ def __init__(
self.config.forcings.nws.windrot = gridgr3.Windrot.default(
self.config.hgrid
)
self.param.opt.model_type_pahm = self.config.forcings.nws.model

self.param.opt.wtiminc = self.param.core.dt
self.param.opt.nws = self.config.forcings.nws.dtype.value
Expand Down
22 changes: 21 additions & 1 deletion pyschism/forcing/nws/best_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import io
import logging
import os
from os import PathLike
import pathlib
from enum import IntEnum
from os import PathLike
from typing import Union

from matplotlib import pyplot
Expand All @@ -24,6 +25,12 @@
from pyschism.mesh import gridgr3


class HurricaneModel(IntEnum):
SYMMETRIC = 1
GAHM = 10



class BestTrackForcing(VortexTrack, NWS):

def __init__(
Expand All @@ -32,8 +39,10 @@ def __init__(
start_date: datetime = None,
end_date: datetime = None,
mode: ATCF_Mode = None,
hurricane_model: HurricaneModel = HurricaneModel.GAHM
):

self._model = hurricane_model

VortexTrack.__init__(
self,
Expand Down Expand Up @@ -99,6 +108,17 @@ def dtype(self) -> NWSType:
"""Returns the datatype of the object"""
return NWSType(-1)

@property
def model(self) -> HurricaneModel:
"""Return hurricane model used for this best track forcing"""
return self._model

@model.setter
def model(self, value: HurricaneModel):
if value not in list(HurricaneModel):
raise ValueError(f"Invalid hurricane model specified: {value}")
self._model = value

def clip_to_bbox(self, bbox, bbox_crs):
msg = f'bbox must be a {Bbox} instance.'
assert isinstance(bbox, Bbox), msg
Expand Down
2 changes: 1 addition & 1 deletion pyschism/forcing/source_sink/nwm.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def safe_extract(tar, path=".", members=None, *, numeric_owner=False):
if not is_within_directory(path, member_path):
raise Exception("Attempted Path Traversal in Tar File")

tar.extractall(path, members, numeric_owner)
tar.extractall(path, members, numeric_owner=numeric_owner)


safe_extract(src, DATADIR)
Expand Down

0 comments on commit 3474ce2

Please sign in to comment.