Stratopy Documentation

Stratopy consists of five main modules. It’s available modules and documentation are listed below.

stratopy.cloudsat module

Module containing all CloudSat satellite related classes and methods.

class stratopy.cloudsat.CloudSatFrame(data)

Bases: object

Make the CloudSatFrame.

DataFrame used for manipulating Cloudsat and GOES data throughout this package.

Attributes
data: attr.ib

satellite image data.

Methods

convert_coordinates([projection])

Convert the coordinates of the CloudSatFrame.

cut([area])

Cut a specified area of an image.

convert_coordinates(projection='+proj=geos +h=35786023.0 +lon_0=-75.0             +x_0=0 +y_0=0 +ellps=GRS80 +units=m +no_defs +sweep=x')

Convert the coordinates of the CloudSatFrame.

Convert the coordinates of the CloudSatFrame in accordance to the defined projection.

Parameters
projectionstring, optional

The reprojection that the user desires, by default the geostationary projection for GOES-R ( “+proj=geos +h=35786023.0 +lon_0=-75.0 +x_0=0 +y_0=0 +ellps=GRS80 +units=m +no_defs +sweep=x” )

Returns
cloudsat.CloudSatFrame

Returns reprojected CloudSatFrame.

cut(area=None)

Cut a specified area of an image.

Cuts a specified area of an image given in as a list of four elements, which correspond to the latitud and longitud limits of the crop operation.

Parameters
arealist of four elements, optional
The list should be [lat_0, lat_1, lon_0, lon_1] where:
  • lat_0, latitude of minimal position

  • lat_1, latitude of maximal position

  • lon_0, longitude of minimal position

  • lon_1, longitude of maximal position

by default cut will be south hemisphere.

Returns
cloudsat.CloudSatFrame

Data frame cropped in the specified latitud and longitud interval.

Raises
ValueError

If the area list does not contain 4 elements.

stratopy.cloudsat.attach_vdata(vs, varname)

Needed to obtain data from hd4 file.

Operation that allows to extract the data from the hd4 format file that CloudSat is saved in.

Parameters
vspyhdf.VS.VS

Data from CloudSat image in hdf4 format.

varnamestring

Name of the variable that wants to be loaded.

Returns
array-like

Data of selected variable obtained from hdf4 Cloudsat file.

stratopy.cloudsat.read_hdf(path, layer='CloudLayerType')

Read CloudSat data files, with extension “.hdf”.

Parameters
file_path: ``str``

String containing local path to file.

layer: ``str``, optional (default=”CloudLayerType”)

Select any layer of the hdf file.

Returns
pandas.DataFrame:

Dataframe containing Latitude, Longitude and 10 layers separated in columns.

stratopy.core module

Contains methods to perform transformation operations on loaded images.

stratopy.core.colfil2scan(col, row, x0=-0.151844, y0=0.151844, scale=5.6e-05)

Reproject into radians.

Transforms columns/rows of the image into x/y en geostationary projection. Based on PUG3 5.1.2.8.2

Parameters
colint, int arr

Selected column.

rowint, int arr

Selected row.

x0float

Position of the first coordinate x[0] in radians.

y0float

Horizontal coordinate of the first spot, in radians. Paralell to Earth’s axis

scalefloat

Pixel size in radians.

Returns
xfloat, float arr

Horizontal coordinate, in radianes.

yfloat, float arr

Vertical coordinate, in radianes. Paralell to Earth’s axis.

stratopy.core.gen_vect(col_row, band_dict)

Generate 3D vector.

For a given (col,row) coordinate, generates a matrix of size 3x3xN where the central pixel is the one located in (col, fil) coordinate. N should be 1 if the goes object contains one band CMI, N should be 3 if the goes object contains three band CMI, N should be 16 if goes object is a multi-band CMI.

Parameters
col_rowtuple

Column and row coordinates given as (col, row).

band_dictdict

Dictionary where bands are defined.

Returns
array-like

Band vector.

stratopy.core.latlon2scan(lat, lon, lon0=-75.0, Re=6378137.0, Rp=6356752.31414, h=35786023.0)

Convert geographical to scan coordinates.

Transform latitud/longitud coordinates into x/y geoestationary projection. Based on PUG3 5.1.2.8.2

Parameters
lat: float, float arr

Latitude.

lon: float, float arr

Longitude.

lon0float

Satellite’s longitude, origin of plane coordinate system.

Re: float

Equatorial radius, in m.

Rp: float

Polar radius, in m.

h: float

Satellite’s height, in m.

Returns
xfloat, float arr

Horizontal coordinate, in radianes.

yfloat, float arr

Vertical coordinate, in radianes. Paralell to Earth’s axis.

stratopy.core.merge(cloudsat_obj, goes_obj, all_layers=False, no_clouds=False, norm=True)

Merge data from Cloudsat with co-located data from GOES-16.

Parameters
cloudsat_obj: ``cloudsat.CloudSatFrame``

Stratopy Cloudsat object.

goes_obj: ``goes.Goes``

Stratopy Goes object.

all_layers: bool

If True, the final dataframe should include all layers of the CLDCLASS product. Default: False

no_clouds: bool

If Ture, the final dataframe should include coordinates where no clouds were detected by CloudSat. Default: False

norm: bool

If True, normalizes all GOES channels [0,1]. Default:True

Returns
Cloudsat Object

DataFrame containing merged data.

stratopy.core.sat2latlon(sx, sy, sz, lon0=-75.0, Re=6378137.0, Rp=6356752.31414, h=35786023.0)

Convert satellite to geographic coordinates.

Transforms cartesian coordinates with origin in the satellite sx,sy,sz into latitude/longitude coordinates. Based on PUG3 5.1.2.8.1

Parameters
sxfloat, float arr

Coordinate pointing to the Earth’s center.

syfloat, float arr

Horizontal coordinate.

szfloat, float arr

Vertical coordinate.

lon0float

Satellite’s longitude, origin of plane coordinate system.

Re: float

Equatorial radius, in m.

Rp: float

Polar radius, in m.

h: float

Satellite’s height, in m.

Returns
latfloat, float arr

Latitude coordinates.

lonfloat, float arr

Longitude coordinates.

stratopy.core.scan2colfil(x_y, x0=-0.151844, y0=0.151844, scale=5.6e-05, tipo=1)

Get the coordinate possition.

Converts x/y coordinates (scan projection) into (row,column) coordinates, a geostationary projection. Based on PUG3, version 5.2.8.2

Parameters
x_yfloat tuple, float arr

Tuple containig, in radians, (horizontal coordinate x, vertical coordinate y).

x0float

Position of the first x cooridnate x[0] in radians.

y0float

Horizontal coordinate of the first spot, in radians. Paralell to Earth’s axis.

scalefloat

Pixel size, in radians.

tipoTYPE, optional

Output type, 0 for float, 1 for int. Default: 1

Returns
col

column number coordinate.

row

Row number coordinate.

stratopy.core.scan2sat(x, y, Re=6378137.0, Rp=6356752.31414, h=35786023.0)

Convert scan to satellite coordinates.

Transform x,y geostationary scan coordinates into cartesian coordinates with origin on the satellite. Based PUG3, version 5.2.8.1.

Parameters
xfloat, float arr numpy.ma.core.MaskedArray

Horizontal coordinate, in radians.

yfloat, float arr numpy.ma.core.MaskedArray

Vertical coordinate, in radians. Parallel to earth’s axis. longitud

Re: float

Equatorial radius, in m.

Rp: float

Polar radius, in m.

h: float

Satellite’s height, in m.

Returns
sxfloat, float arr

Coordinate pointing to the center of the Earth.

syfloat, float arr

Horizontal coordinate.

szfloat, float arr

Vertical coordinate.

stratopy.goes module

Module containing all GOES satellite related classes and methods.

class stratopy.goes.Goes(data, coordinates=(-40.0, 10.0, -37.0, -80.0))

Bases: object

Treat the GOES files.

Generates an object containing the Day Microphysics state according to GOES-16 manual, along with all with all netCDF.Dataset variables of original data.

Parameters
data: ``netCDF4.Dataset.variables dict``

Dictionary with variables data from each channel of the GOES Day Microphysics product.

coordinates: ``tuple`` (default: cut will be south hemisphere)
(lat_inf, lat_sup, lon_east, lon_west) where:

lat_inf, latitude of minimal position lat_sup, latitude of maximal position lon_east, longitude of lon_west, longitude of

Methods

trim()

Drop the GOES image.

trim()

Drop the GOES image.

Trims a GOES CMI image according to coordinate: lower latitude, upper latitude, eastern longitude, western longitude specified on the parameters. Default parameters are set to return a South America image.

Parameters
None
Returns
trim_img: numpy.array containing the trimmed image.
stratopy.goes.mask(rgb)

Correct the RGB.

This function returns a labeled-by-color image according to the interpretation of the product Day Microphysics (https://weather.msfc.nasa.gov/sport/training/quickGuides/ rgb/QuickGuide_DtMicroRGB_NASA_SPoRT.pdf)

Parameters
rgb: numpy array

Object containig the Day Microphysics RGB product.

Returns
img_mask: numpy array

Masked RGB.

stratopy.goes.read_nc(file_path, **kwargs)

Read netCDF files through the netCDF4 library.

Parameters
file_pathstr tuple

Contains a file path of one or all three paths to channels 3, 7 and 13 of the CMIPF GOES-16 product. Can also contain a single path to all 16 channels of MCMIPF GOES-16 product.

Returns
goes.Goes

Object with all netCDF.Dataset variables along with GOES16 Day Microphysics.

stratopy.goes.rgb2hsi(image)

Convert a RGB image to a HSI image.

Parameters
image: ``numpy.array``

Numpy Array object containig a RGB image.

Returns
HSI: numpy.array

Image in HSI color system.

stratopy.goes.solar7(trim_coord_ch7, ch7, ch13)

Correct the channel 7.

This function does a zenith angle correction to channel 7. This correction is needed for day time images. It is used in RGB method of Goes class.

Parameters
trim_coord_ch7: ``tuple``
(r0, r1, c0, c1) where:

r0, latitude of r1, latitude of c0, longitude of c1, longitude of

ch7: ``numpy.array``

Trimmed image of channel 7.

ch13: ``numpy.array``

Trimed image of channel 13.

Returns
numpy.array

Zenith calculation for every pixel for channel 7.

stratopy.IO module

Module containing magement function.

stratopy.IO.fetch(cloudsat_id, goes_id, cloudsat_kw=None, goes_kw=None)

Run both fetches for CloudSat and GOES data and merges them.

Parameters
cloudsat_idstr

Path to cloudsat image.

goes_idstr

Path to GOES image.

cloudsat_kwstr, optional

Label to append to Cloudsat cached file, by default None

goes_kwstr, optional

Label to append to Cloudsat cached file, by default None

Returns
merger.StratoFrame

Resulting merged DataFrame from both inputs.

stratopy.IO.fetch_cloudsat(dirname, user, passwd, host='ftp.cloudsat.cira.colostate.edu', tag='stratopy-cloudsat', path=PosixPath('/home/docs/stratopy_cache'))

Get cloudsat files.

Fetch files of a certain date from cloudsat ftp server and stores in a local cache.

Parameters
dirnamestr

Path to cloudsat image.

userstr

Username for cloudsat ftp connection.

passwdstr

Password for cloudsat ftp connection.

hoststr, optional

Name of the url where the file is hosted.

tagstr, optional

Tag to be added to the cached file.

pathstr, optional

Path where to save the cached file.

Returns
dfstratopy.cloudsat.CloudSatFrame

Dataframe containing the image data.

stratopy.IO.fetch_goes(dirname, tag='stratopy-goes', path=PosixPath('/home/docs/stratopy_cache'))

Get GOES files.

Fetch files of a certain date from GOES server and stores in a local cache.

Parameters
dirnamestr

Name of the cached file.

tagstr

Tag to append to name of cached file.

pathstr

Location where to save the cached file.

Returns
goes_objnetCDF4.Dataset

GOES image data.