Miscellaneous#
parcels.rng module#
- parcels.rng.expovariate(lamb)[source]#
Returns a random float of an exponential distribution with parameter lamb.
parcels.tools.statuscodes module#
Handling of Errors and particle status codes
- exception parcels.tools.statuscodes.FieldOutOfBoundError(x, y, z, field=None)[source]#
Bases:
RuntimeError
Utility error class to propagate out-of-bound field sampling.
- exception parcels.tools.statuscodes.FieldSamplingError(x, y, z, field=None)[source]#
Bases:
RuntimeError
Utility error class to propagate erroneous field sampling.
- exception parcels.tools.statuscodes.KernelError(particle, fieldset=None, msg=None)[source]#
Bases:
RuntimeError
General particle kernel error with optional custom message.
parcels.tools.converters module#
- class parcels.tools.converters.Geographic[source]#
Bases:
UnitConverter
Unit converter from geometric to geographic coordinates (m to degree)
Methods
ccode_to_source
ccode_to_target
to_source
to_target
- class parcels.tools.converters.GeographicPolar[source]#
Bases:
UnitConverter
Unit converter from geometric to geographic coordinates (m to degree) with a correction to account for narrower grid cells closer to the poles.
Methods
ccode_to_source
ccode_to_target
to_source
to_target
- class parcels.tools.converters.GeographicPolarSquare[source]#
Bases:
UnitConverter
Square distance converter from geometric to geographic coordinates (m2 to degree2) with a correction to account for narrower grid cells closer to the poles.
Methods
ccode_to_source
ccode_to_target
to_source
to_target
- class parcels.tools.converters.GeographicSquare[source]#
Bases:
UnitConverter
Square distance converter from geometric to geographic coordinates (m2 to degree2)
Methods
ccode_to_source
ccode_to_target
to_source
to_target
- class parcels.tools.converters.TimeConverter(time_origin=0)[source]#
Bases:
object
Converter class for dates with different calendars in FieldSets
- Parameters
time_origin (float, integer, numpy.datetime64 or netcdftime.DatetimeNoLeap) – time origin of the class.
Methods
fulltime
(time)Method to convert a time difference in seconds to a date, based on the time_origin
reltime
(time)Method to compute the difference, in seconds, between a time and the time_origin of the TimeConverter
- class parcels.tools.converters.UnitConverter[source]#
Bases:
object
Interface class for spatial unit conversion during field sampling that performs no conversion.
- Attributes
- source_unit
- target_unit
Methods
ccode_to_source
ccode_to_target
to_source
to_target
parcels.tools.loggers module#
Script to create a logger for Parcels.
parcels.tools.exampledata_utils module#
- parcels.tools.exampledata_utils.download_example_dataset(dataset: str, data_home=None)[source]#
Load an example dataset from the parcels website.
This function provides quick access to a small number of example datasets that are useful in documentation and testing in parcels.
- Parameters
dataset (str) – Name of the dataset to load.
data_home (pathlike, optional) – The directory in which to cache data. If not specified, the value of the
PARCELS_EXAMPLE_DATA
environment variable, if any, is used. Otherwise the default location is assigned byget_data_home()
.
- Returns
dataset_folder – Path to the folder containing the downloaded dataset files.
- Return type
Path
- parcels.tools.exampledata_utils.get_data_home(data_home=None)[source]#
Return a path to the cache directory for example datasets.
This directory is used by
load_dataset()
.If the
data_home
argument is not provided, it will use a directory specified by thePARCELS_EXAMPLE_DATA
environment variable (if it exists) or otherwise default to an OS-appropriate user cache location.
- parcels.tools.exampledata_utils.list_example_datasets() List[str] [source]#
List the available example datasets.
Use
download_example_dataset()
to download one of the datasets.- Returns
datasets – The names of the available example datasets.
- Return type
list of str