Movie Routines
gcmprocpy provides a range of functions for data visualization. Below are the key plotting routines along with their detailed parameters and usage examples.
API
Loading Datasets
This function loads the netCDF datasets for the plotting routines.
- gcmprocpy.io.load_datasets(directory, dataset_filter=None)[source]
Loads netCDF datasets for the plotting routines.
- Parameters:
directory (str) – The location of the directory where the files are stored or the path to a single file.
dataset_filter (str, optional) – The string to filter the NetCDF files to select from (e.g., ‘prim’, ‘sech’). Defaults to None.
- Returns:
A list containing tuples, each with an xarray.Dataset object and the corresponding filename and model in string.
- Return type:
list[tuple]
Closing Datasets
This function closes the netCDF datasets.
Warning
This function should be called after the plotting routines have been executed.
- gcmprocpy.io.close_datasets(datasets)[source]
Closes the xarray datasets.
- Parameters:
datasets (list[tuple]) – A list containing tuples, each with an xarray.Dataset object and the corresponding filename and model in string.
- Returns:
None
Latitude vs Longitude Contour Movie
This function generates a sequence of contour plots of a variable against latitude and longitude over time and creates a video animation.
- gcmprocpy.mov_gen.mov_lat_lon(datasets, variable_name, level=None, variable_unit=None, center_longitude=0, contour_intervals=None, contour_value=None, symmetric_interval=False, cmap_color=None, cmap_lim_min=None, cmap_lim_max=None, line_color='white', coastlines=False, nightshade=False, gm_equator=False, latitude_minimum=None, latitude_maximum=None, longitude_minimum=None, longitude_maximum=None, time_minimum=None, time_maximum=None, fps=None, clean_plot=False)[source]
Generates a Latitude vs Longitude contour plot for a variable and creates a video of the plot over time.
- Parameters:
datasets (xarray.Dataset) – The loaded dataset/s using xarray.
variable_name (str) – The name of the variable with latitude, longitude, and lev/ilev dimensions.
level (float, optional) – The selected lev/ilev value. Defaults to None.
variable_unit (str, optional) – The desired unit of the variable. Defaults to None.
center_longitude (float, optional) – The central longitude for the plot. Defaults to 0.
contour_intervals (int, optional) – The number of contour intervals. Defaults to None.
contour_value (int, optional) – The value between each contour interval. Defaults to None.
symmetric_interval (bool, optional) – If True, the contour intervals will be symmetric around zero. Defaults to False.
cmap_color (str, optional) – The color map of the contour. Defaults to None.
cmap_lim_min (float, optional) – Minimum limit for the color map. Defaults to the minimum value of the variable.
cmap_lim_max (float, optional) – Maximum limit for the color map. Defaults to the maximum value of the variable.
line_color (str, optional) – The color for all lines in the plot. Defaults to ‘white’.
coastlines (bool, optional) – Shows coastlines on the plot. Defaults to False.
nightshade (bool, optional) – Shows nightshade on the plot. Defaults to False.
gm_equator (bool, optional) – Shows geomagnetic equator on the plot. Defaults to False.
latitude_minimum (float, optional) – Minimum latitude to slice plots. Defaults to None.
latitude_maximum (float, optional) – Maximum latitude to slice plots. Defaults to None.
longitude_minimum (float, optional) – Minimum longitude to slice plots. Defaults to None.
longitude_maximum (float, optional) – Maximum longitude to slice plots. Defaults to None.
time_minimum (Union[np.datetime64, str], optional) – Minimum time for the plot. Defaults to None.
time_maximum (Union[np.datetime64, str], optional) – Maximum time for the plot. Defaults to None.
fps (int, optional) – Frames per second for the video. Defaults to None.
- Returns:
A video file of the contour plot over the specified time range.
- Return type:
Video file
- Example:
Load datasets and generate a video animation of Latitude vs Longitude contour plots over time.
from your_module import mov_lat_lon # Replace 'your_module' with the actual module name datasets = load_datasets(directory, dataset_filter) # Ensure to define your load_datasets function variable_name = 'TN' level = 4.0 time_min = '2024-01-01T00:00:00' time_max = '2024-01-02T00:00:00' fps = 5 mov_lat_lon(datasets, variable_name, level=level, time_minimum=time_min, time_maximum=time_max, fps=fps)