Open a wind dataset from file by memory-mapping
Datasets downloaded from the NOAA are stored as large binary files that are memmapped into the predictor process and thereby treated like a huge array.
Dataset contains some utility methods to find/list datasets in a directory, and can open (& create) dataset files.
Note: once opened, the dataset is mmaped as Dataset.array, which by itself is not particularly useful. The tawhiri.download creates a numpy.ndarray from this mapping, and :mod:`tawhiri.interpolate casts it (via a memory view) to a pointer in Cython.
A wind dataset
Open the dataset file for ds_time, in directory
Parameters: |
|
---|
See also
After initalisation, the following attributes are available:
The forecast time of this dataset (datetime.datetime).
…and this method:
Close the dataset
This deletes array, thereby releasing (a) reference to it. Note that other objects may very well hold a reference to the array, keeping it open.
(The file descriptor is closed as soon as the dataset is mapped.)
The following attributes are class attributes:
The dimensions of the dataset
Note len(axes[i]) == shape[i].
The values of the points on each axis: a 5-(named)tuple (hour, pressure variable, latitude, longitude).
For example, axes.pressure[4] is 900—points in cells dataset.array[a][4][b][c][d] correspond to data at 900mb.
The data type of dataset elements
The size in bytes of element_type
The size in bytes of the entire dataset
The filename suffix for “grib mirror” files
The default location of wind data
These “utility” class methods are available:
Returns the filename under which we expect to find a dataset
... for forecast time ds_time, in directory with an optional suffix
Parameters: |
|
---|---|
Return type: | string |
Scan for datasets in directory
... with filenames matching those generated by filename() and (optionally) filter by only looking for certian suffices.
Parameters: | |
---|---|
Return type: | (named) tuples (dataset time, suffix, filename, full path) |
Wind tahwiri.wind.Dataset Downloader
Downloaded data arrives in GRIB format, although three quarters of the records in the downloaded file are ignored. The records that are used can also be written to a new grib file as they are unpacked (which is therefore somewhat smaller, as it is still compressed and only contains the useful bits).
Bases: builtins.object
Unpack the GRIB file at filename
... into dataset
... copying the GRIB records we care about into gribmirror
... checking that the forecastTime matches assert_hour
callback must _not_ edit dataset, checklist or gribmirror, or yield to a greenlet that will (hence DownloadDaemon.unpack_lock).
callback is mainly used to yield to other greenlets doing IO (i.e., downloading other files) while we do the CPU intensive task of unpacking GRIB data.
The data is unpacked in two passes; the first
The second pass copies the data in each record to its correct location in dataset, writes a copy to gribmirror and marks the correct place in checklist as True.
ValueError is raised in case of any problems.
Produce a function that can get wind data from dataset (a tawhiri.dataset.Dataset).
This function returns a closure:
Returns: | delta lat, lon and alt |
---|
See also
implementation
Provide all the balloon models, termination conditions and functions to combine models and termination conditions.
Make a model chain for the typical floating balloon situation of ascent at constant altitude to a float altitude which persists for some amount of time before stopping. Descent is in general not modelled.
Return a terminator that terminates when any of terminators would terminate.
Return a burst-termination criteria, which terminates integration when the altitude reaches burst_altitude.
Return a constant-ascent model at ascent_rate (m/s)
Return a descent-under-parachute model with sea level descent sea_level_descent_rate (m/s). Descent rate at altitude is determined using an altitude model courtesy of NASA: http://www.grc.nasa.gov/WWW/K-12/airplane/atmosmet.html
For a given altitude the air density is computed, a drag coefficient is estimated from the sea level descent rate, and the resulting terminal velocity is computed by the returned model function.
A termination criteria which terminates integration when the altitude goes below ground level, using the elevation data in dataset (which should be a ruaumoko.Dataset).
Return a model that returns the sum of all the models in models.
A time based termination criteria, which terminates integration when the current time is greater than max_time (a UNIX timestamp).
Return a wind-velocity model, which gives lateral movement at the wind velocity for the current time, latitude, longitude and altitude. The dataset argument is the wind dataset in use.
A termination criteria which terminates integration when the altitude is less than (or equal to) zero.
Note that this is not a model factory.
Make a model chain for the standard high altitude balloon situation of ascent at a constant rate followed by burst and subsequent descent at terminal velocity under parachute with a predetermined sea level descent rate.
Requires the balloon ascent_rate, burst_altitude and descent_rate, and additionally requires the dataset to use for wind velocities.
Returns a tuple of (model, terminator) pairs.
Solve from initial conditions t, lat, lng and alt, using models and termination criteria from chain, an iterable of (model, terminator) pairs which make up each stage of the flight.
Provide the HTTP API for Tawhiri.
Bases: builtins.Exception
Base API exception.
Bases: tawhiri.api.APIException
Raised when an internal error occurs.
Bases: tawhiri.api.APIException
Raised if the dataset specified in the request is invalid.
Bases: tawhiri.api.APIException
Raised when the functionality has not yet been implemented.
Bases: tawhiri.api.APIException
Raised if the solver raises an exception.
Bases: tawhiri.api.APIException
Raised if request is invalid.
Tawhiri is trajectory prediction software for high altitude balloons.
See http://www.cusf.co.uk/wiki/tawhiri:start for further details.