Closed SorooshMani-NOAA closed 1 year ago
@WPringle I just noticed that separate_tracks
is doing most of the work. It creates a dictionary of dictionary of dataframes. The outer dictionary keys are advisory names, e.g. OFCL
, CARQ
, HWRF
, etc. the inner dictionary keys are track_start_time
s (or best_track_time
for best track). This means that if you get the full atcf-file dataframe and then call separate_tracks
on it, you can get a track with specific advisory_name
and track_start_time
. For example
import stormevents
track = stormevents.nhc.VortexTrack.from_storm_name('harvey', 2017, file_deck='a')
track_dict = stormevents.nhc.track.separate_tracks(track.data)
track_of_interest = track_dict['OFCL']['20170824T060000']
This covers the use-case, but maybe we can make it easier by adding an API like:
track_of_interest = track.get_track(advisory_name, datetime)
which basically executes the steps above, but can, for example, accept datetime object instead of string formatted time. What do you think?
Update
calling track.tracks
already takes care of calling stormevents.nhc.track.separate_tracks(track.data)
and returns the track_dict
@SorooshMani-NOAA Interesting. We could just use this but then need think about start_time
and end_time
. It could be fine to just say that is only relevant for best_track? Then still need to add capability to fill in CARQ from previous times if we want to spin up.
@SorooshMani-NOAA I tried doing this and it works to get back a dataframe but now I can't write out to .to_file
as a fort.22/ATCF .dat.
@WPringle, you need to create a new VortexTrack
object now using this dataframe. You can just pass it like filtered_track = VortexTrack(my_filtered_df, file_deck=THESAMEASBEFORE, advisories=THESAMEASBEFORE)
and then call to_file
on the new object.
@SorooshMani-NOAA Interesting thanks. So this is my working example (that works):
from stormevents.nhc import VortexTrack
if __name__ == '__main__':
event = VortexTrack(
storm='al062018',
advisories='OFCL',
file_deck='a',
)
tracks = event.tracks
track = tracks['OFCL']['20180912T180000']
track = VortexTrack(track, file_deck='a', advisories='OFCL')
track.to_file('stormevents_adv54.dat',overwrite=True)
@SorooshMani-NOAA Maybe if we can make this into a single function could be good!
Fixed by #82
Feature request by @WPringle: An API to choose a specific advisory based on the track start date.