Skip to Content.

mget-help - RE: [mget-help] MGET python only

Please Wait...

Subject: Marine Geospatial Ecology Tools (MGET) help

Text archives


RE: [mget-help] MGET python only


Chronological Thread 
  • From: Jason Roberts <>
  • To: Olivia Cabrera <>
  • Cc: "" <>
  • Subject: RE: [mget-help] MGET python only
  • Date: Mon, 14 Jan 2019 19:53:44 +0000
  • Accept-language: en-US
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:99

Dear Olive,

 

Thanks for your interest in MGET. To install MGET without ArcGIS, simply install 32-bit Python 2.7 (get the Windows x86 MSI installer from here) and then follow steps 4-6 of the instructions on the MGET download page. The MGET installer will warn you that ArcGIS is not installed but you can acknowledge the warning and carry on.

 

Note that MGET is currently only compatible with numpy up to version 1.11.2. If you have already installed Python and a newer version of numpy yourself, you will have to replace your version of numpy with 1.11.2 or an earlier version. We are sorry for this inconvenience. MGET is mainly used by ArcGIS users, for whom ArcGIS itself installs Python and numpy, so we usually only update our numpy compatibility when ArcGIS updates theirs.

 

Below my signature is a script that demonstrates how to detect fronts in a GHRSST L4 SST dataset available from NASA PO.DAAC. This relies on Python classes in MGET that are only partially documented. After installing MGET, you can find some documentation under your Windows Start menu under Marine Geospatial Ecology Tools. We were unable to secure the funding needed to offer MGET with a documented API. I do what I can as part of other projects, but I have no direct funding for MGET so my availability for it is limited. Nevertheless, if you are skilled in Python (or can readily learn it) I should be able to point you in the right direction to accomplish front and eddy detection. It could be quite a lot of work for you, however, so you should be prepared.

 

All the best,

 

Jason

 

 

import datetime, os, sys

import numpy

 

# Define parameters controlling the script.

 

product = 'CMC0.1deg-CMC-L4-GLOB-v3.0'  # GHRSST Level 4 product to download

                                        # from NASA PO.DAAC. Must be one that

                                        # is supported by MGET.

                                       

outputDir = 'C:\\Temp\\SSTFronts'       # Output directory to receive rasters.

 

# Define the focal area and time. As a demonstration, we will use the

# area of the Atlantic where strong fronts may be observed along the

# Gulf Stream, and process the first week of data for 2019. The

# spatial and temporal extent that is available depends on which

# GHRSST L4 product is used.

 

xMin = -82

xMax = -52

yMin = 25

yMax = 45

tMin = datetime.datetime(2019,1,1)

tMax = datetime.datetime(2019,1,8)

 

# Initialize MGET's logging. GeoEco is the Python package name used by MGET.

 

from GeoEco.Logging import Logger

Logger.Initialize()

 

# Create the output directory and a directory within it to hold cached

# data from the NASA server. The cache directory is not necessary but

# will prevent us from downloading the same data multiple times.

 

cacheDir = os.path.join(outputDir, 'Cache')

if not os.path.isdir(cacheDir):

    os.makedirs(cacheDir)

 

# Instantiate an internal MGET object representing the GHRSST L4 time

# series of images as a gridded dataset with 3 dimensions.

 

from GeoEco.DataProducts.NASA.PODAAC import GHRSSTLevel4

 

[rdacCode, productType, areaCode, areaCode2, gdsVersion, fileVersion,

productCode, productCode2, applyMask, customPathParsingExpressions

] = GHRSSTLevel4._PODAAC_Products[product]

 

grid = GHRSSTLevel4('analysed_sst', product, rdacCode, productType, areaCode,

                    areaCode2, gdsVersion, fileVersion, productCode,

                    productCode2, applyMask, customPathParsingExpressions,

                    cacheDirectory=cacheDir)

 

# Clip the grid spatially and temporally. This does not actually

# download anything. It just wraps the original grid in something that

# will clip it.

 

from GeoEco.Datasets.Virtual import ClippedGrid

 

grid = ClippedGrid(grid, 'Map coordinates', xMin=xMin, xMax=xMax, yMin=yMin,

                   yMax=yMax, tMin=tMin, tMax=tMax)

# Download SST images. This step is not necessary to detect fronts,

# but we want to show the fronts overlaid on the SST images, so we

# need the images themselves. Create the images as rasters in ERDAS

# Imagine format (.img files) using GDAL, which is included privately

# in MGET. You can choose another format if desired.

 

from GeoEco.Datasets import QueryableAttribute

from GeoEco.Datasets.Collections import DirectoryTree

from GeoEco.Datasets.GDAL import GDALDataset

from GeoEco.Datasets.Virtual import GridSliceCollection

from GeoEco.Types import DateTimeTypeMetadata

 

datasets = GridSliceCollection(grid, tQACoordType=u'min').QueryDatasets()

 

qa = tuple(grid.GetAllQueryableAttributes() + [QueryableAttribute(u'DateTime', u'Date', DateTimeTypeMetadata())])

 

outputDirTree = DirectoryTree(path=outputDir,

                              datasetType=GDALDataset,

                              pathCreationExpressions=['SST', '%%Y', '%%Y%%m%%d_sst.img'],

                              queryableAttributes=qa)

 

outputDirTree.ImportDatasets(datasets=datasets,

                             mode='Replace')    # Change to Add to not recreate them each time you run

 

# Instantiate an object that will detect fronts using the Canny (1986)

# edge detection algorithm. Note that this requires that the MATLAB

# Component Runtime (MCR) version 7.7 be installed. This is freely

# available. For more information, see:

# http://code.nicholas.duke.edu/projects/mget/wiki/MCR.

# You can download it directly from:

# http://code.nicholas.duke.edu/projects/mget/export/HEAD/WikiFiles/MCR/v77/win32/MCRInstaller.exe

#

# The Cayula and Cornillon (1992) single image edge detection (SIED)

# algorithm is also available but more complicated to implement and

# optimize, and does not necessarily give better results, in my

# opinion. (However I have not produced evidence that demonstrates

# this, so my opinion should be considered cautiously.)

 

from GeoEco.Datasets.Virtual import CannyEdgeGrid

 

frontsGrid = CannyEdgeGrid(grid)

 

# Create the fronts images as rasters. This actually executes the

# algorithm in a "just in time" style during the ImportDatasets call.

 

datasets = GridSliceCollection(frontsGrid, tQACoordType=u'min').QueryDatasets()

 

outputDirTree = DirectoryTree(path=outputDir,

                              datasetType=GDALDataset,

                              pathCreationExpressions=['Fronts', '%%Y', '%%Y%%m%%d_fronts.img'],

                              queryableAttributes=qa)

 

outputDirTree.ImportDatasets(datasets=datasets,

                            mode='Replace')

 

From: <> On Behalf Of Olivia Cabrera
Sent: Monday, January 14, 2019 12:07 AM
To:
Subject: [mget-help] MGET python only

 

Dear Sir/Madam:

 

I am very interested in the Marine Geospatial Ecology Tools, especially the Front Detection and the Okubo-Weiss tools.  However, we do not have ARCGIS and would like to install it and use it with just Python. Your website says it is possible and I would appreciate help in the installation.  Thank you.

 

Best regards,

Olive

--

Olivia Cabrera, PhD

Institute of Environmental Science and Meteorology
University of the Philippines, Diliman, Quezon City, PHIL 1101
http://www.iesm.upd.edu.ph
Tel: +63 9818500 loc 3947 or 3950




Archive powered by MHonArc 2.6.19.

Top of Page