pyModis

Table Of Contents

Previous topic

pyModis Library

PDF documentation

Download the documentation in pdf format



pyModis Package

downmodis module: is very useful to download MODIS data from NASA FTP server

class pymodis.downmodis.downModis(password, destinationFolder, user='anonymous', url='e4ftl01.cr.usgs.gov', tiles=None, path='MOLT/MOD11A1.005', today=None, enddate=None, delta=10, jpg=False, debug=False)[source]

A class to download MODIS data from NASA FTP repository

checkDataExist(listNewFile, move=0)[source]

Check if a file already exists in the directory of download

listNewFile = list of all files, returned by getFilesList function

move = it is useful to know if a function is called from download or move function

closeFTP()[source]

Close ftp connection

connectFTP(ncon=20)[source]

Set connection to ftp server, move to path where data are stored and create a list of directories for all days

ncon = number maximum of test to connection at the ftp server

dayDownload(listFilesDown)[source]

Downloads tiles are in files_hdf_consider

listFilesDown = list of the files to download, returned by checkDataExist function

debugDays()[source]

This function is useful to debug the number of days

debugLog()[source]

Function to create the debug file

debugMaps()[source]

This function is useful to debug the number of maps to download for each day

downloadsAllDay(clean=False, allDays=False)[source]

Downloads all the tiles considered

getAllDays()[source]

Return a list of all days

getFilesList()[source]

Create a list of files to download, it is possible choose to download also the jpeg files or only the hdf files

getListDays()[source]

Return a list of all selected days

getNewerVersion(oldFile, newFile)[source]

Return newer version of a file

oldFile = one of the two similar file

newFile = one of the two similar file

removeEmptyFiles()[source]

Check if some file has size ugual 0

setDirectoryIn(day)[source]

Enter in the directory of the day

setDirectoryOver()[source]

Come back to old path

parsemodis module: is very simple library to parse MODIS metadata file, it can also write the XML metadata file for a mosaic.

class pymodis.parsemodis.parseModis(filename)[source]

Class to parse MODIS xml files, it also can create the parameter configuration file for resampling MODIS DATA with the MRT software or convertmodis Module

confResample(spectral, res=None, output=None, datum='WGS84', resample='NEAREST_NEIGHBOR', projtype='GEO', utm=None, projpar='( 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 )')[source]

Create the parameter file to use with resample MRT software to create tif file

spectral = the spectral subset to be used, look the product table to understand the layer that you want use. For example:

  • NDVI ( 1 1 1 0 0 0 0 0 0 0 0 0) copy only layer NDVI, EVI and QA VI the other layers are not used
  • LST ( 1 1 0 0 1 1 0 0 0 0 0 0 ) copy only layer daily and nightly temperature and QA

res = the resolution for the output file, it must be set in the map unit of output projection system. The software will use the original resolution of input file if res it isn’t set

output = the output name, if it doesn’t set will use the prefix name of input hdf file

utm = the UTM zone if projection system is UTM

resample = the type of resampling, the valid values are:
  • NN (nearest neighbor)
  • BI (bilinear)
  • CC (cubic convolution)
projtype = the output projection system, the valid values are:
  • AEA (Albers Equal Area)
  • ER (Equirectangular)
  • GEO (Geographic Latitude/Longitude)
  • HAM (Hammer)
  • ISIN (Integerized Sinusoidal)
  • IGH (Interrupted Goode Homolosine)
  • LA (Lambert Azimuthal)
  • LCC (LambertConformal Conic)
  • MERCAT (Mercator)
  • MOL (Mollweide)
  • PS (Polar Stereographic)
  • SIN (Sinusoidal)
  • UTM (Universal TransverseMercator)
datum = the datum to use, the valid values are:
  • NAD27
  • NAD83
  • WGS66
  • WGS76
  • WGS84
  • NODATUM

projpar = a list of projection parameters, for more info check the Appendix C of MODIS reprojection tool user manual https://lpdaac.usgs.gov/content/download/4831/22895/file/mrt41_usermanual_032811.pdf

confResample_swath(sds, geoloc, res, output=None, sphere='8', resample='NN', projtype='GEO', utm=None, projpar='0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0')[source]

Create the parameter file to use with resample MRT software to create tif file

sds = Name of band/s (Science Data Set) to resample

geoloc = Name geolocation file (example MOD3, MYD3)

res = the resolution for the output file, it must be set in the map unit of output projection system. The software will use the original resolution of input file if res it isn’t set

output = the output name, if it doesn’t set will use the prefix name of input hdf file

sphere = Output sphere number. Valid options are:
  • 0=Clarke 1866
  • 1=Clarke 1880
  • 2=Bessel
  • 3=International 1967
  • 4=International 1909
  • 5=WGS 72
  • 6=Everest
  • 7=WGS 66
  • 8=GRS1980/WGS 84
  • 9=Airy
  • 10=Modified Everest
  • 11=Modified Airy
  • 12=Walbeck
  • 13=Southeast Asia
  • 14=Australian National
  • 15=Krassovsky
  • 16=Hough
  • 17=Mercury1960
  • 18=Modified Mercury1968
  • 19=Sphere 19 (Radius 6370997)
  • 20=MODIS Sphere (Radius 6371007.181)
resample = the type of resampling, the valid values are:
  • NN (nearest neighbor)
  • BI (bilinear)
  • CC (cubic convolution)
projtype = the output projection system, the valid values are:
  • AEA (Albers Equal Area)
  • ER (Equirectangular)
  • GEO (Geographic Latitude/Longitude)
  • HAM (Hammer)
  • ISIN (Integerized Sinusoidal)
  • IGH (Interrupted Goode Homolosine)
  • LA (Lambert Azimuthal)
  • LCC (LambertConformal Conic)
  • MERCAT (Mercator)
  • MOL (Mollweide)
  • PS (Polar Stereographic),
  • SIN ()Sinusoidal)
  • UTM (Universal TransverseMercator)

utm = the UTM zone if projection system is UTM

projpar = a list of projection parameters, for more info check the Appendix C of MODIS reprojection tool user manual https://lpdaac.usgs.gov/content/download/4831/22895/file/mrt41_usermanual_032811.pdf

getGranule()[source]

Set the GranuleURMetaData element

getRoot()[source]

Set the root element

retBoundary()[source]

Return the maximum extend (Bounding Box) of the MODIS file as dictionary

retBrowseProduct()[source]

Return the BrowseProduct element

retCollectionMetaData()[source]

Return the CollectionMetaData element as dictionary

retDTD()[source]

Return the DTDVersion element

retDataCenter()[source]

Return the DataCenterId element

retDataFiles()[source]

Return the DataFiles element as dictionary

retDataGranule()[source]

Return the ECSDataGranule elements as dictionary

retDbID()[source]

Return the DbID element

retGranuleUR()[source]

Return the GranuleUR element

retInputGranule()[source]

Return the input files (InputGranule) used to process the considered file

retInsertTime()[source]

Return the InsertTime element

retLastUpdate()[source]

Return the LastUpdate element

retMeasure()[source]

Return statistics of QA as dictionary

retPGEVersion()[source]

Return the PGEVersion element

retPSA()[source]

Return the PSA values as dictionary, the PSAName is the key and and PSAValue is the value

retPlatform()[source]

Return the platform values as dictionary.

retRangeTime()[source]

Return the RangeDateTime elements as dictionary

class pymodis.parsemodis.parseModisMulti(hdflist)[source]

A class to obtain some variables for the xml file of several MODIS tiles. It can also create the xml file

valBound()[source]

Function return the Bounding Box of mosaic

valCollectionMetaData(obj)[source]

Function to add CollectionMetaData

obj = element to add CollectionMetaData

valDTD(obj)[source]

Function to add DTDVersion

obj = element to add DTDVersion

valDataCenter(obj)[source]

Function to add DataCenter

obj = element to add DataCenter

valDataFiles(obj)[source]

Function to add DataFileContainer

obj = element to add DataFileContainer

valDbID(obj)[source]

Function to add DbID

obj = element to add DbID

valGranuleUR(obj)[source]

Function to add GranuleUR

obj = element to add GranuleUR

valInputPointer(obj)[source]

Function to add InputPointer

obj = element to add InputPointer

valInsTime(obj)[source]

Function to add the minimum of InsertTime

obj = element to add InsertTime

valMeasuredParameter(obj)[source]

Function to add ParameterName

obj = element to add ParameterName

valPGEVersion(obj)[source]

Function to add PGEVersion

obj = element to add PGEVersion

valPlatform(obj)[source]

Function to add Platform elements

obj = element to add Platform elements

valRangeTime(obj)[source]

Function to add RangeDateTime

obj = element to add RangeDateTime

writexml(outputname)[source]

Write a xml file for a mosaic

outputname = the name of xml file

convertmodis module: using MRT software, can convert MODIS HDF file to GeoTiff file or create a HDF mosaic file for several tiles.

class pymodis.convertmodis.convertModis(hdfname, confile, mrtpath)[source]

A class to convert modis data from hdf to tif using resample (from MRT tools)

executable()[source]

Return the executable of resample MRT software

run()[source]

Exec the convertion process

class pymodis.convertmodis.createMosaic(listfile, outprefix, mrtpath, subset=False)[source]

A class to convert several MODIS tiles into a mosaic

executable()[source]

Return the executable of mrtmosaic MRT software

run()[source]

Exect the mosaic process

write_mosaic_xml()[source]

Write the XML metadata file for MODIS mosaic

class pymodis.convertmodis.processModis(hdfname, confile, mrtpath, inputhdf=None, outputhdf=None, geolocfile=None)[source]

A class to process raw modis data from hdf to tif using swath2grid (from MRT Swath tools)

executable()[source]

Return the executable of resample MRT software

run()[source]

Exec the convertion process