Reference¶
Mango class¶
- class mangopy.Mango(datadir=None, download_data=False)[source]¶
Bases:
object
Object for accessing and ploting data from a single MANGO camera.
- Parameters
datadir (str, optional) – Path to exisiting directory containing MANGO data.
download_data (bool, optional) – If True, downloads data from ftp server.
- fetch_datafile(site, date, save_directory=None)[source]¶
Fetches mango data from online repository. Curtesy of AReimer’s url_fetcher() function.
- Parameters
site (str) – Camera site name.
date (datetime object) – Date image was taken.
save_directory (str, optional) – Directory where files will be saved.
- get_data(site, targtime)[source]¶
Accesses the images and position of a site, given the site name and time.
- Parameters
site (str) – Camera site name
targtime (datetime object) – Time of image as requested by user.
- Returns
img_array (array) – Image array
lat (float) – Latitude array
lon (float) – Longitude array
truetime (datetime object) – Time at which image was taken.
- get_site_info(sites)[source]¶
Obtains information about sites given as user input.
- Parameters
sites (list) – List of sites.
- Returns
site_list – List of dictionaries with information about sites.
- Return type
list
- map(site, targtime)[source]¶
Plots a single MANGO image on the map.
- Parameters
site (str) – Camera site name
targtime (datetime object) – Time of image as requested by user.
- plot(site, targtime)[source]¶
Plots a single MANGO image.
- Parameters
site (str) – Camera site name
targtime (datetime object) – Time of image as requested by user.
- read_datafile(filename, targtime)[source]¶
Helper function for getting data; reads data in from hdf5 file.
- Parameters
filename (str) – hdf5 filename
targtime (datetime object) – Time of image as requested by user
- Returns
img_array (array) – Image array
lat (float) – Latitude array
lon (float) – Longitude array
truetime (datetime object) – Time image was taken
Mosaic class¶
- class mangopy.Mosaic(sites='all', datadir=None)[source]¶
Bases:
mangopy.mango.Mango
Object for creating and visualizing mosaics of all cameras in the MANGO network.
- Parameters
sites (list, optional) – Sites to be plotted as mosaic on map.
datadir (str, optional) – Path to exisiting directory containing MANGO data.
- create_all_mosaic(date, saveFig=False)[source]¶
Creates all mosaic images for a particular date. Images should be approximately 5 minutes apart.
- Parameters
date (datetime object) – Date for which mosaic is created.
- create_mosaic(time, cell_edges=False)[source]¶
Creates the background grid for images at specifed time.
- Parameters
time (datetime object) – User requested time.
cell_edges (boolean, optional) – Draws cell edges if set to True.
- Returns
combined_grid (array) – Background grid image.
grid_lat_values (array) – Grid latitude values.
grid_lon_values (array) – Grid longitude values.
- create_mosaic_movie(date)[source]¶
Creates a movie of all mosaic images for particular date. Requires ffmpeg to be installed.
- Parameters
date (datetime object) – Date for which mosaic movie is created.
- generate_grid()[source]¶
Create base background grid. Original images have the following approximate resolution:
lat_res ~ 0.025 degrees
lon_res ~ 0.035 degrees
- Returns
grid_array (array) – Array of grid latitude and longitude values.
edge_array (array) – Array of edge latitude and longitude values.
- get_nearest_index(site, background_grid, time)[source]¶
Gets nearest neighbor interpolation indices for the specifed site.
- Parameters
site (str) – Site for which you need indices.
background_grid (array) – Base background grid.
time (datetime object) – Time of image as requested by user.
- Returns
nearest_idx – Nearest index of each image cell closest to grid cell.
- Return type
array
- grid_mosaic(time, grid, hierarchy)[source]¶
Creates combined grid based on hierarchy.
- Parameters
time (datetime object) – Time of images on mosaic as requested by user.
grid (array) – Base background grid.
hierarchy (array) – Hierarchy of sites to be plotted.
- Returns
combined_grid (array) – Combined grid.
truetime (datetime object) – Time images were taken.
- haversine(lat0, lon0, lat, lon)[source]¶
Calculates distance (in km) between two points on Earth, assuming spherical Earth.
- Parameters
lat0 (float) – Latitude of site.
lon0 (float) – Longitude of site.
lat (float) – Latitude of grid.
lon (float) – Longitude of grid.
- Returns
km – Haversine distance in kilometers.
- Return type
float
- plot_mosaic(time, dpi=300, saveFig=False)[source]¶
Plots images of sites closest to requested time on map with grid.
- Parameters
time (datetime object) – Time of images on mosaic as requested by user.
dpi (int, optional) – Defaults to 300.
saveFig (boolean, optional) – Saves figure of mosaic if set to True.
- site_hierarchy(grid_points)[source]¶
Calculates site hierarchy for common grid based on the distance of each point from each site. Site hierarchy is used to determine which camera to plot in each cell of the mosaic.
- Parameters
grid_points (array) – Coordinate points of base background grid.
- Returns
hierarchy – Array containing hierarchy of sites.
- Return type
array