API Reference
PlateModelManager
The plate_model_manager.PlateModelManager
class manages the plate reconstruction models.
You can use this class to do the things listed below.
Get a list of available model names.
Get a
plate_model_manager.PlateModel
object for a specific model name.Download all models into a folder.
- class plate_model_manager.PlateModelManager(model_manifest: str = '', timeout=(None, None))[source]
Bases:
object
Manage a set of publicly available plate reconstruction models. The model files are hosted on EarthByte servers. You need Internet connection to use this class and download the files.
- __init__(model_manifest: str = '', timeout=(None, None))[source]
Constructor. Create a
PlateModelManager
instance. You need Internet connection to create an instance of this class. If you don’t have Internet connection, usePlateModel
class directly inreadonly
mode. Visit this page to see an example.- Parameters:
model_manifest – The URL to a
models.json
metadata file. Normally you don’t need to provide this parameter unless you would like to setup your own plate model server.
- download_all_models(data_dir: str = './') None [source]
Download all available models into the
data_dir
.- Parameters:
data_dir (str) – The folder to save the model files.
- static get_local_available_model_names(local_dir: str)[source]
Return a list of model names in a local folder.
- Parameters:
local_dir (str) – The local folder containing models.
- get_model(model_name: str = 'default', data_dir: str = '.') PlateModel | None [source]
Return a
PlateModel
object for a given plate model name.Call
get_available_model_names()
to see a list of available plate model names.- Parameters:
model_name – the plate model name of interest
data_dir – The folder to save the plate model files. This
data_dir
can be changed withPlateModel.set_data_dir()
later.
- Returns:
a
PlateModel
object orNone
if the plate model name is no good.
PlateModel
The plate_model_manager.PlateModel
class manages the files in a plate reconstruction model.
You can use this class to do the things listed below.
Get a list of available layers in a plate model.
Download the rotation file(s).
Download the layer file(s) for a specific layer.
Download time-dependent raster files.
Download all files in a plate model.
- class plate_model_manager.PlateModel(model_name: str, model_cfg=None, data_dir: str = '.', readonly=False, timeout=(None, None))[source]
Bases:
object
Download and manage files required for a plate reconstruction model.
👀👇 LOOK HERE!!! 👀👇
Normally you should always use
PlateModelManager.get_model()
to get aPlateModel
object. Create aPlateModel
object directly only when you don’t have Internet connection and would like to use the local model files inreadonly
mode. Do not create aPlateModel
object directly if you have no idea what’s going on.- __init__(model_name: str, model_cfg=None, data_dir: str = '.', readonly=False, timeout=(None, None))[source]
Constructor. Create a
PlateModel
instance.- Parameters:
model_name (str) – The model name of interest.
model_cfg – The model configuration in JSON format. The configuration is either downloaded from the server or loaded from a local file
.metadata.json
. If you are confused by this parameter, usePlateModelManager.get_model()
to get aPlateModel
object instead.data_dir (str, default=".") – The folder path to save the model data.
readonly (bool, default=False) – If this flag is set to
True
, ThePlateModel
object will use the files in the local folder and will not attempt to download/update the files from the server.timeout – Network connection timeout parameter.
- create_model_dir()[source]
Create a folder with a file
.metadata.json
in it to keep the model files.
- download_all_layers()[source]
Download all layers. This function calls
download_layer_files()
on every available layer.
- download_time_dependent_rasters(raster_name, times=None)[source]
Download time-dependent rasters for a given raster name.
Call
get_avail_time_dependent_raster_names()
to see all the available raster names in this model.- Parameters:
raster_name – the raster name of interest
times – if not given, download from begin to end with 1My interval
- get_COBs(return_none_if_not_exist: bool = False) List[str] | None [source]
Return a list of
Continent-Ocean Boundaries
files.
- get_avail_time_dependent_raster_names()[source]
Return all time-dependent raster names in this plate model.
- get_coastlines(return_none_if_not_exist: bool = False) List[str] | None [source]
Return a list of
coastlines
files.
- get_continental_polygons(return_none_if_not_exist: bool = False) List[str] | None [source]
Return a list of
continental polygons
files.
- get_data_dir()[source]
Return the path to a folder (parent folder of the
model dir
) containing a set of downloaded models.
- get_layer(layer_name: str, return_none_if_not_exist: bool = False) List[str] | None [source]
Get a list of layer files by a layer name. Call
get_avail_layers()
to get all the available layer names.Raise
LayerNotFoundInModel
exception to get user’s attention by default. Setreturn_none_if_not_exist
toTrue
if you don’t want to see theLayerNotFoundInModel
exception.- Parameters:
layer_name – The layer name of interest.
return_none_if_not_exist – If set to
True
, returnNone
when the layer does not exist in the model.
- Returns:
A list of file names or
None
ifreturn_none_if_not_exist
is set toTrue
.
:raises
LayerNotFoundInModel
: Raise this exception if the layer name does not exist in this model.
- get_raster(raster_name: str, time: int | float) str [source]
Return a local path for the raster file.
- get_rasters(raster_name: str, times: List[int | float]) List[str] [source]
Return local paths for the raster files.
- Parameters:
times – A list of times
- Returns:
A list of local paths
- get_static_polygons(return_none_if_not_exist: bool = False) List[str] | None [source]
Return a list of
static polygons
files.
- get_topologies(return_none_if_not_exist: bool = False) List[str] | None [source]
Return a list of
topologies
files.
- static is_model_dir(folder_path: str)[source]
Return
True
if the folder contains files of a plate model, otherwiseFalse
.
PresentDayRasterManager
The plate_model_manager.PresentDayRasterManager
class manages the present-day rasters.
You can use this class to do the things listed below.
Get a list of available present-day raster names.
Download a specific present-day raster.
- class plate_model_manager.PresentDayRasterManager(data_dir='present-day-rasters', raster_manifest=None)[source]
Bases:
object
Manage the present-day rasters.
- __init__(data_dir='present-day-rasters', raster_manifest=None)[source]
Constructor. Create a
PresentDayRasterManager
instance.- Parameters:
raster_manifest – The URL to a
present_day_rasters.json
metadata file. Normally you don’t need to provide this parameter unless you would like to setup your own present-day raster server.data_dir – The path to a folder to save the present-day raster files.
- get_raster(_name: str, width=1800, height=800, bbox=[-180, -80, 180, 80], large_file_hint=True)[source]
Download a raster file by name, save the raster file in
self.data_dir
and return the local path to the raster file.Call
list_present_day_rasters()
to see a list of available present-day raster names.
Auxiliary Function
Auxiliary functon for users’ convenience.
- plate_model_manager.get_plate_model(model_name: str, data_dir: str | PathLike) PlateModel | None [source]
Convenient function to create a
PlateModel
instance using best effort. First, try to get the plate model withPlateModelManager
. If the servers cannot be reached, try to use the local plate model files which were previously downloaded.- Parameters:
model_name – the plate model name of interest
data_dir – The folder to save the plate model files.
- Returns:
a
PlateModel
object orNone
if the plate model name is no good.