Main Modules¶
stormtracks.c20data – C20 Reanalysis Data¶
- class stormtracks.c20data.C20Data(start_year, smoothing=False, upscaling=False, verbose=True)¶
Class used for accessing data from C20 Reanalysis project.
This acts as a wrapper around netCDF4.Datasets and makes it easy to view data. Typically it exposes the psl, vort, and vort4 fields for one ensemble member. (vort4 is calculated using a 4th order vorticity calculation.) It will load these fields, along with corresponding maxima (vorticity) and minima (pressure) each time a new date is set for an object.
Parameters: - start_year – Year from which to take data
- smoothing – Apply smoothing to data fields
- upscaling – Upscale data using cubic splines
- verbose – Prints lots of output
- close_datasets()¶
Closes all open datasets
- cvorticity(u, v)¶
Calculates the (2nd order) vorticity by calling into a c function
- cvorticity4(u, v)¶
Calculates the (4th order) vorticity by calling into a c function
Algorithm was taken from Walsh’s code
- first_date(ensemble_member=0, ensemble_mode='member')¶
Sets date to the first date of the year (i.e. Jan the 1st)
- fourth_order_vorticity(u, v)¶
Calculates the (4th order) vorticity using python
Algorithm was taken from Walsh’s code
- load_datasets(year)¶
Loads datasets for a given year
If self.ensemble == True it will load the datasets with each ensemble member. Otherwise it will load the ensemble means datasets.
- next_date(ensemble_member=0, ensemble_mode='member')¶
Moves date on by one timestep (6hr)
- prev_date(ensemble_member=0, ensemble_mode='member')¶
Moves date back by one timestep (6hr)
- set_date(date, ensemble_member=0, ensemble_mode='member')¶
Sets date and loads all data for that date
Will have no effect if there is no difference in date or ensemble_member.
Parameters: - date – date to load
- ensemble_member – ensemble member to load
- ensemble_mode – whether to load an individual member or take an average
Returns: date if successful, otherwise None
- set_year(year)¶
Sets a year and loads the relevant dataset
- vorticity(u, v)¶
Calculates the (2nd order) vorticity using python
- class stormtracks.c20data.GlobalEnsembleMember(c20data, ensemble_member=0)¶
Wrapper around a C20Data object
holds state of which ensemble member is currently being analysed
- set_date(date)¶
Sets the date, does nothing if it is the same as the stored date
- set_year(year)¶
Change the year of the stored C20Data object
stormtracks.ibtracsdata – IBTrACS Data¶
- class stormtracks.ibtracsdata.IbStormtrack(year, name)¶
Holds info about an IBTrACS best track
- class stormtracks.ibtracsdata.IbtracsData(data_dir=None, verbose=True)¶
Class used for accessing IBTrACS data
Wraps the underlying NetCDF4 files and extracts the infromation required from them.
Parameters: - data_dir – directory where IBTrACS NetCDF4 files are held
- verbose – whether to pring lots of output
- load_ibtracks_year(year, basin='NA')¶
Loads a given year’s worth of data
Parameters: - year – year to load
- basin – which basins to load (‘all’ for all of them)
Returns: list of loaded best tracks
- load_wilma_katrina()¶
Loads only best tracks corresponding to Wilma and Katrina (2005)
stormtracks.tracking – Tracking of Features¶
- class stormtracks.tracking.VortMax(date, pos, vort)¶
Holds key info (date, position, vorticity value) about a vorticity maximum.
To serialize this class (or any that contain objects of this class) you must make sure next_vortmax/prev_vortmax are None.
Parameters: - date – date of vortmax
- pos – position (2 element tuple)
- vort – vorticity value
- add_next(vortmax)¶
Used to make doubly linked list of vortmaxes
- class stormtracks.tracking.VortMaxTrack(start_vortmax)¶
Stores a collection of VortMax objects in a list and adds them to a dict that is accessible through a date for easy access.
- class stormtracks.tracking.VortmaxFinder(gdata)¶
Finds all vortmaxes for a given ensemble member
Parameters: gdata – GlobalEnsembleMember to use - find_vort_maxima(start_date, end_date, use_upscaled=False)¶
Runs over the date range looking for all vorticity maxima
- class stormtracks.tracking.VortmaxKalmanFilterTracker(Q_mult=0.001, R_mult=0.1)¶
Uses a Kalman Filter to try to track vorticity maxima
The main idea is to use the innovation parameter from the Kalman Filter estimation process as a measure of how likely it is that a vorticity maxima in a subsequent timestep belongs to the same track as a vorticity maxima in the current timestep
- track_vort_maxima(vortmax_time_series)¶
Uses a generated list of vortmaxes to track them from one timestep to another
Parameters: vortmax_time_series – dict of vortmaxes Returns: self.vort_tracks_by_date (OrderedDict)
- class stormtracks.tracking.VortmaxNearestNeighbourTracker¶
Simple nearest neighbour tracker
Assumes that the two nearest points from one timestep to another belong to the same track.
- track_vort_maxima(vortmax_time_series)¶
Uses a generated list of vortmaxes to track them from one timestep to another
Parameters: vortmax_time_series – dict of vortmaxes Returns: self.vort_tracks_by_date (OrderedDict)
stormtracks.tracking – Matching of Tracks¶
- class stormtracks.match.Match(best_track, vort_track)¶
Represents one match between a best track and a vorticity track
- av_dist()¶
Returns the average distance between the best and vorticity tracks
- stormtracks.match.combined_match(best_tracks, all_matches)¶
Uses all best tracks and matches to combine all matches for each best track
Parameters: - best_tracks – list of best tracks
- all_matches – all matches to search through
Returns: dict of combined_matches (key: best track, value: list of matches)
- stormtracks.match.match(vort_tracks_by_date, best_tracks)¶
Takes all vorticity tracks and best tracks and matches them up
Uses CUM_DIST_CUTOFF to decide whether the two tracks are too far apart
Parameters: - vort_tracks_by_date – dict with dates as keys and lists of vort tracks as values
- best_tracks – list of best tracks
Returns: OrderedDict of Match objects * key: (best_track, vortmax) tuple * value: Match object
stormtracks.results – Store and Access Results¶
- class stormtracks.results.StormtracksResult(dct)¶
Utility class that is easier to use than a dict
Parameters: dct – dict used to populate this class’ fields
- class stormtracks.results.StormtracksResultsManager¶
Manager class that is responsible for loading and saving all results
Load/saves to settings.OUTPUT_DIR. Saves each result based on its year/ensemble_member (using that as a directory/filename structure). Saves each result as a name in a dictionary that then gets serialized to disk.
- add_result(year, ensemble_member, name, result)¶
Adds a given result based on year, ensemble_member and a user chosen name
- delete(year=2005, ensemble_member=0)¶
Deletes a specific result from disk
- get_result(year, ensemble_member)¶
Gets a set of results based on year, ensemble_member
- list_ensemble_members(year)¶
List all results saved for a particular year
- list_years()¶
List all saved years
- load(year=2005, ensemble_member=0)¶
Loads results from disk
- print_list_years()¶
Print all saved results
- save()¶
Saves all results that have been added so far