Skip to Content.

mget-help - RE: [mget-help] MGET-0.8a60 fails to convert NASA OBPG NetCDF4-CF SMI

Please Wait...

Subject: Marine Geospatial Ecology Tools (MGET) help

Text archives


RE: [mget-help] MGET-0.8a60 fails to convert NASA OBPG NetCDF4-CF SMI


Chronological Thread 
From: Jason Roberts <>
To: "White, George" <>
Cc: "" <>
Subject: RE: [mget-help] MGET-0.8a60 fails to convert NASA OBPG NetCDF4-CF SMI
Date: Mon, 10 Aug 2015 15:15:10 +0000
Accept-language: en-US
Authentication-results: spf=none (sender IP is ) ;
Spamdiagnosticmetadata: NSPM
Spamdiagnosticoutput: 1:23

George,

Attached is a quick script for batch converting a 2D variable from a 
directory of netCDF4 files. The variable must be in a "geographic" coordinate 
system with square cells. The files must include complete CF-compliant 
metadata, with lat and lon variables, etc. The OceanColor netCDFs include all 
the required stuff, so if SeaDAS automatically puts it in, you should be able 
to use this script as-is. If not all the metadata is there, you must add code 
to the script to supply the needed info. The script assumes the input files 
end in .nc and that you want to create .img rasters.

Here's an example run, converting two chlorophyll files:

D:\Temp\OceanColor_Example>Convert_NetCDF4s.py 
D:\Temp\OceanColor_Example\netCDFs D:\Temp\OceanColor_Example\Rasters chlor_a
2015-08-10 11:05:39,997 INFO Querying directory 
D:\Temp\OceanColor_Example\netCDFs for datasets matching the expression 
"VariableName = 'chlor_a'".
2015-08-10 11:05:40,161 INFO Query complete: 0:00:00 elapsed, 2 datasets 
found, 0:00:00.065000 per dataset.
2015-08-10 11:05:40,176 INFO Importing 2 datasets into ArcGIS Folder 
D:\Temp\OceanColor_Example\Rasters with mode "add".
2015-08-10 11:05:40,193 INFO Checking for existing destination datasets.
2015-08-10 11:05:40,203 INFO Finished checking: 0:00:00 elapsed, 2 datasets 
checked, 0:00:00.000500 per dataset.
2015-08-10 11:05:40,217 INFO 0 destination datasets already exist. Importing 
2 datasets.
2015-08-10 11:06:04,262 INFO Import complete: 0:00:24 elapsed, 2 datasets 
imported, 0:00:12.016000 per dataset.

This script requires ArcGIS 10.3 or later. It relies on the Python netCDF4 
module which ESRI began including with their Python installation starting 
with 10.3. If you do not have 10.3 or later, you can manually install the 
Python netCDF4 module.

Hope this helps. Feel free to ask questions.

Jason

-----Original Message-----
From: White, George 
[mailto:]
 
Sent: Friday, August 07, 2015 12:14 PM
To: Jason Roberts 
<>
Cc: 

Subject: RE: [mget-help] MGET-0.8a60 fails to convert NASA OBPG NetCDF4-CF SMI

Thanks for the prompt reply.  It is sadly true that current economic and 
political realities have slowed work progress for many ocean ecology groups, 
but that is certainly nothing to cause embarrassment.   

We do create our own products with SeaDAS, and have users who need ArcGIS 
rasters.   In addition to unique products, we also provide higher spatial 
resolution for regions much smaller than NASA's global  SMI's.  We have been 
producing geotiffs, but those don't preserve the metadata (band names, units, 
etc.) so users have to provide metadata manually in ArcGIS or via python 
scripts.  Users should be quite happy with Python scripts that can read 
NetCDF4-CF files.  Any hints in that direction you can provide would be 
welcome.

-----Original Message-----
From: Jason Roberts 
[mailto:]
 
Sent: August-07-15 12:01 PM
To: White, George
Cc: 

Subject: RE: [mget-help] MGET-0.8a60 fails to convert NASA OBPG NetCDF4-CF SMI

George,

Thanks for your interest in MGET. Sadly--it is embarrassing to say--I have 
not had time to update that tool to work with netCDF4. It is failing because 
it only works with netCDF3.

Much of the underlying work has been completed, to the point that it is 
possible to write relatively simple Python scripts that can do the 
conversion. But I haven't done the work of updating the code that exposes it 
as an ArcGIS tool.

If you are interested in the L3 images available from NASA already--e.g. that 
you can access from the OceanColor L3 browser 
(http://oceancolor.gsfc.nasa.gov/cgi/l3)--then you can use the tools under 
MGET --> Data Products --> NASA GFSC OceanColor Group --> L3 Products.

But it sounds like you are creating your own data with SeaDAS. If that is the 
case, then unfortunately there is no ArcGIS-exposed tool in MGET yet that can 
help. If you are interested, I may be able to update the tool you are using 
sometime near the end of this month. Or if you are comfortable programming in 
Python, I could send some example code sooner that would illustrate how to do 
the conversion. Finally, if you prefer a command-line solution, you might be 
able to use GDAL to do it (the gdal_translate tool).

All the best,

Jason 

-----Original Message-----
From: 

 
[mailto:]
 
Sent: Friday, August 07, 2015 10:35 AM
To: 

Subject: [mget-help] MGET-0.8a60 fails to convert NASA OBPG NetCDF4-CF SMI

The test NetCDF4-CF file was created with SeaDAS 7.2 OCSSW Processing System 
from the SeaDAS benchmark files:

PS C:\Users\WhiteG\Documents\ArcGIS> C:\Python27\ArcGIS10.2\Scripts\ncinfo.exe
.\A2006167181000.smi_chlor_a_mn.nc
<type 'netCDF4._netCDF4.Dataset'>
root group (NETCDF4 data model, file format HDF5):
    product_name: A2006167181000.smi_chlor_a_mn.nc
    instrument: MODIS
    title: HMODISA Level-3 Standard Mapped Image
    project: Ocean Biology Processing Group (NASA/GSFC/OBPG)
    platform: Aqua
    temporal_range: 1-hour
    processing_version: Unspecified
    date_created: 2015-06-05T15:07:58.000Z
    history: l3mapgen ifile=A2006167181000.L3b_time.nc 
ofile=A2006167181000.smi_chlor_a_mn.nc ofile2=A2006167181000.smi_ 
chlor_a_mn.tif oformat2=tiff product=chlor_a resolution=2km east=-62 west=-78
south=30 north=46
    l2_flag_names:
ATMFAIL,LAND,HILT,HISATZEN,STRAYLIGHT,CLDICE,COCCOLITH,LOWLW,CHLWARN,CHLFAIL,NAVWARN,MAXAERITER,ATMWA
RN,HISOLZEN,NAVFAIL,FILTER,HIGLINT
    time_coverage_start: 2006-06-16T16:10:07.000Z
    time_coverage_end: 2006-06-16T16:15:04.000Z
    start_orbit_number: 21910
    end_orbit_number: 21910
    map_projection: Equidistant Cylindrical
    latitude_units: degrees_north
    longitude_units: degrees_east
    northernmost_latitude: 46.0
    southernmost_latitude: 30.0
    westernmost_longitude: -78.0
    easternmost_longitude: -62.0
    geospatial_lat_max: 46.0
    geospatial_lat_min: 30.0
    geospatial_lon_max: -62.0
    geospatial_lon_min: -78.0
    grid_mapping_name: latitude_longitude
    latitude_step: 0.0208333
    longitude_step: 0.0208333
    sw_point_latitude: 30.0104
    sw_point_longitude: -77.9896
    geospatial_lon_resolution: 2.31916
    geospatial_lat_resolution: 2.31916
    geospatial_lat_units: km
    geospatial_lon_units: km
    spatialResolution: 2.32 km
    number_of_lines: 768
    number_of_columns: 768
    measure: Mean
    suggested_image_scaling_minimum: 0.01
    suggested_image_scaling_maximum: 20.0
    suggested_image_scaling_type: LOG
    suggested_image_scaling_applied: No
    _lastModified: 2015-06-05T15:07:58.000Z
    Conventions: CF-1.6
    institution: NASA Goddard Space Flight Center, Ocean Ecology Laboratory, 
Ocean Biology Processing Group
    standard_name_vocabulary: NetCDF Climate and Forecast (CF) Metadata 
Convention
    Metadata_Conventions: Unidata Dataset Discovery v1.0
    naming_authority: gov.nasa.gsfc.sci.oceandata
    id: L3/A2006167181000.L3b_time.nc
    license:
http://science.nasa.gov/earth-science/earth-science-data/data-information-policy/
    creator_name: NASA/GSFC/OBPG
    publisher_name: NASA/GSFC/OBPG
    creator_email: 

    publisher_email: 

    creator_url: http://oceandata.sci.gsfc.nasa.gov
    publisher_url: http://oceandata.sci.gsfc.nasa.gov
    processing_level: L3 Mapped
    cdm_data_type: grid
    identifier_product_doi_authority: http://dx.doi.org
    identifier_product_doi: 10.5067/AQUA/MODIS_OC.2014.0
    keywords: Oceans > Ocean Chemistry > Chlorophyll; Oceans > Ocean Optics > 
Ocean Color
    keywords_vocabulary: NASA Global Change Master Directory (GCMD) Science 
Keywords
    data_bins: 153375
    data_minimum: 0.0563091
    data_maximum: 98.3519
    dimensions(sizes): lat(768), lon(768), rgb(3), eightbitcolor(256)
    variables(dimensions): float32 ←[4mchlor_a←[0m(lat,lon), float32 
←[4mlat←[0m(lat), float32 ←[4mlon←[0m(lon), uint8 ←
[4mpalette←[0m(rgb,eightbitcolor)
    groups: processing_control

Using ArcGIS 10.2.2, MGET-0.8a60.win32-py2.7, with netCDF4-1.1.9, 
numpy-1.9.2, conversion of the SMI to raster fails:

Executing: NetCDFConvert2DVariableToArcGISRaster
C:\Users\WhiteG\Documents\ArcGIS\A2006167181000.smi_chlor_a_mn.nc
C:\Users\WhiteG\Documents\ArcGIS\Default.gdb\A2006167181000_smi_chlor_a 
chlor_a
-70 30 0.0208333 # false false false false # # # # # # # # false Start Time: 
Fri Aug 07 10:54:23 2015 Running script 
NetCDFConvert2DVariableToArcGISRaster...
Converting variable chlor_a in netCDF file 
C:\Users\WhiteG\Documents\ArcGIS\A2006167181000.smi_chlor_a_mn.nc to ArcGIS 
raster 
C:\Users\WhiteG\Documents\ArcGIS\Default.gdb\A2006167181000_smi_chlor_a...
RuntimeError: Not a netCDF file
Failed script NetCDFConvert2DVariableToArcGISRaster...

Traceback (most recent call last):
  File "C:\Program
Files\GeoEco\ArcGISToolbox\Scripts\NetCDFConvert2DVariableToArcGISRaster.py",
line 5, in <module>
    ExecuteMethodFromCommandLineAsArcGISTool('GeoEco.DataManagement.NetCDFs',
'NetCDF', 'Convert2DVariableToArcGISRaster')
  File "C:\Python27\ArcGIS10.2\lib\site-packages\GeoEco\ArcGISScripts.py", 
line 210, in ExecuteMethodFromCommandLineAsArcGISTool
    exec sourceCode in globals(), locals()
  File "<string>", line 1, in <module>
  File
"C:\Python27\ArcGIS10.2\lib\site-packages\GeoEco\DataManagement\NetCDFs.py",
line 191, in Convert2DVariableToArcGISRaster
    data = cls.GetNumpyArrayFor2DVariableInNetCDFFile(inputFile, variableName)
  File
"C:\Python27\ArcGIS10.2\lib\site-packages\GeoEco\DataManagement\NetCDFs.py",
line 245, in GetNumpyArrayFor2DVariableInNetCDFFile
    dataset = netCDF3.Dataset(netCDFFileTemp, 'r')
  File "netCDF3.pyx", line 691, in netCDF3.Dataset.__init__
(build/src/GeoEco/AssimilatedModules\netCDF3_1_9_2..c:4086)
RuntimeError: Not a netCDF file

Failed to execute (NetCDFConvert2DVariableToArcGISRaster).
Failed at Fri Aug 07 10:54:24 2015 (Elapsed Time: 0.70 seconds)

Note: The test file may have invalid latitudes due to bug in l3mapgen, but I 
would expect to get further along before hitting that problem (and it may be 
useful to see what error the invlaid lats trigger).

Attachment: Convert_NetCDF4s.py
Description: Convert_NetCDF4s.py




Archive powered by MHonArc 2.6.19.

Top of Page