In [2]:
%pylab auto
from netCDF4 import Dataset
import json
Initialize a netCDF data set and set some global attributes.
Global attributes are attached to the whole file, and are included at the recommendation of various conventions.
The following are CF-convention attributes:
In [ ]:
fid = Dataset('MODICE_template.nc', 'w', format='NETCDF4')
fid.Conventions = "CF-1.6"
fid.title = "MEaSUREs Calibrated Passive Microwave Daily EASE-Grid 2.0 Brightness Temperature ESDR"
fid.product_version = "v0.01"
fid.software_version_id = "TBD"
fid.software_repository = "git@bitbucket.org:nsidc/measures-byu.git"
fid.source = "TBD(list of swath files used)"
fid.source_version_id = "TBD(list of GSX versions, 1 per source file)"
fid.history = "TBD(bgi or sir command line)"
fid.comment = "Prototype version of this product, intended for user evaluation and feedback."
fid.references = ["Data set documentation: http://nsidc.org/data/nsidc-0630.html\n",
"Algorithm Theoretical Basis Document: http://nsidc.org/pmesdr/files/2015/09/MEaSUREs_CETB_ATBD_v0.10.pdf\n",
"Ancillary File: TBD"]
fid.summary = ["An improved, enhanced-resolution, gridded passive microwave Earth System Data Record \n",
"for monitoring cryospheric and hydrologic time series\n" ]
fid.institution = ["National Snow and Ice Data Center\n",
"Cooperative Institute for Research in Environmental Sciences\n",
"University of Colorado at Boulder\n",
"Boulder, CO"]
fid.publisher = ["National Snow and Ice Data Center\n",
"Cooperative Institute for Research in Environmental Sciences\n",
"University of Colorado at Boulder\n",
"Boulder, CO"]
fid.publisher_url = "http://nsidc.org"
fid.publisher_email = "nsidc@nsidc.org"
fid.project = "NASA 2012 MEaSUREs (Making Earth System Data Records for Use in Research Environments)"
fid.standard_name_vocabulary = "CF Standard Name Table (v27, 28 September 2013)"
fid.cdm_data_type = "grid"
fid.keywords = "EARTH SCIENCE > SPECTRAL/ENGINEERING > MICROWAVE > BRIGHTNESS TEMPERATURE"
fid.keywords_vocabulary = "NASA Global Change Master Directory (GCMD) Earth Science Keywords, Version 8.1"
fid.platform = "TBD"
fid.sensor = "TBD"
fid.naming_authority = "org.doi.dx"
fid.id = "10.5067/MEASURES/CRYOSPHERE/nsidc-0630.001"
fid.date_created = "TBD"
fid.acknowledgement = ["This data set was created with funding from NASA MEaSUREs Grant #NNX13AI23A.\n",
"Data archiving and distribution is supported by the NASA NSIDC Distributed Active Archive Center (DAAC)."]
fid.license = "No constraints on data access or use"
fid.processing_level = "Level 3"
fid.creator_name = "Mary J. Brodzik"
fid.creator_email = "brodzik@nsidc.org"
fid.creator_url = "http://nsidc.org/pmesdr"
fid.contributor_name = "Mary J. Brodzik, David G. Long, Molly A. Hardman, Aaron C. Paget"
fid.contributor_role = "Principal Investigator, Co-Investigator, Developer, Contributor"
fid.citation = ["Brodzik, M. J., D. G. Long, M. A. Hardman, A. C. Paget. 2015.\n",
"MEaSUREs Calibrated Passive Microwave Daily EASE-Grid 2.0 Brightness Temperature ESDR.\n",
"Version 0.01.\n",
"[Indicate subset used].\n",
"Boulder, Colorado USA: NASA DAAC at the National Snow and Ice Data Center." ]
The following fields that are defined here are expected to be overwritten at run-time by cetb_file calls:
In [ ]:
references = json.dumps([ "EASE-Grid 2.0 documentation: http://nsidc.org/data/ease/ease_grid2.html",
"Brodzik, Mary J.; Billingsley, Brendan; Haran, Terry; Raup, Bruce; Savoie, Matthew H. 2012.",
"EASE-Grid 2.0: Incremental but Significant Improvements for Earth-Gridded Data Sets.",
"ISPRS Int. J. Geo-Inf. 1, no. 1: 32-45.",
"Brodzik, Mary J.; Billingsley, Brendan; Haran, Terry; Raup, Bruce; Savoie, Matthew H. 2014.",
"Correction: Brodzik, M. J., et al. EASE-Grid 2.0: Incremental but Significant Improvements for Earth-Gridded Data Sets.",
"ISPRS Int. J. Geo-Inf. 3, no. 3: 1154-1156."
])
# EASE-Grid 2.0 North
crsN = fid.createVariable( 'crs_EASE2_N', 'S1', () )
crsN.long_name = "TBD"
crsN.grid_mapping_name = "lambert_azimuthal_equal_area"
crsN.longitude_of_projection_origin = 0.0
crsN.latitude_of_projection_origin = 90.0
crsN.false_easting = 0.0
crsN.false_northing = 0.0
crsN.scale_factor_at_projection_origin = 0.0
crsN.proj4text = "+proj=laea +lat_0=90 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m"
crsN.srid = "urn:ogc:def:crs:EPSG::6931"
crsN.references = references
crsN.crs_wkt = "PROJCRS[\"WGS 84 / NSIDC EASE-Grid 2.0 North\", BASEGEODCRS[\"WGS 84\", DATUM[\"World Geodetic System 1984\", ELLIPSOID[\"WGS 84\",6378137,298.257223563,LENGTHUNIT[\"metre\",1.0]]]], CONVERSION[\"US NSIDC EASE-Grid 2.0 North\", METHOD[\"Lambert Azimuthal Equal Area\",ID[\"EPSG\",9820]], PARAMETER[\"Latitude of natural origin\",90,ANGLEUNIT[\"degree\",0.01745329252]], PARAMETER[\"Longitude of natural origin\",0,ANGLEUNIT[\"degree\",0.01745329252]], PARAMETER[\"False easting\",0,LENGTHUNIT[\"metre\",1.0]], PARAMETER[\"False northing\",0,LENGTHUNIT[\"metre\",1.0]]], CS[cartesian,2], AXIS[\"easting (X)\",south,MERIDIAN[90,ANGLEUNIT[\"degree\",0.01745329252]],ORDER[1]], AXIS[\"northing (Y)\",south,MERIDIAN[180,ANGLEUNIT[\"degree\",0.01745329252]],ORDER[2]], LENGTHUNIT[\"metre\",1.0], ID[\"EPSG\",6931]]"
# EASE-Grid 2.0 South
crsS = fid.createVariable( 'crs_EASE2_S', 'S1', () )
crsS.long_name = "TBD"
crsS.grid_mapping_name = "lambert_azimuthal_equal_area"
crsS.longitude_of_projection_origin = 0.0
crsS.latitude_of_projection_origin = -90.0
crsS.false_easting = 0.0
crsS.false_northing = 0.0
crsS.scale_factor_at_projection_origin = 0.0
crsS.proj4text = "+proj=laea +lat_0=-90 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m"
crsS.srid = "urn:ogc:def:crs:EPSG::6932"
crsS.references = references
crsS.crs_wkt = "PROJCRS[\"WGS 84 / NSIDC EASE-Grid 2.0 South\", BASEGEODCRS[\"WGS 84\", DATUM[\"World Geodetic System 1984\", ELLIPSOID[\"WGS 84\",6378137,298.257223563,LENGTHUNIT[\"metre\",1.0]]]], CONVERSION[\"US NSIDC EASE-Grid 2.0 South\", METHOD[\"Lambert Azimuthal Equal Area\",ID[\"EPSG\",9820]], PARAMETER[\"Latitude of natural origin\",-90,ANGLEUNIT[\"degree\",0.01745329252]], PARAMETER[\"Longitude of natural origin\",0,ANGLEUNIT[\"degree\",0.01745329252]], PARAMETER[\"False easting\",0,LENGTHUNIT[\"metre\",1.0]], PARAMETER[\"False northing\",0,LENGTHUNIT[\"metre\",1.0]]], CS[cartesian,2], AXIS[\"easting (X)\",north,MERIDIAN[90,ANGLEUNIT[\"degree\",0.01745329252]],ORDER[1]], AXIS[\"northing (Y)\",north,MERIDIAN[0,ANGLEUNIT[\"degree\",0.01745329252]],ORDER[2]], LENGTHUNIT[\"metre\",1.0], ID[\"EPSG\",6932]]"
# EASE-Grid 2.0 Temperate/Tropical
# CF convention http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/build/apf.html
# says cylindrical projection needs:
# longitude_of_central_meridian
# standard_parallel OR scale_factor_at_projection_origin
# false_easting
# false northing
# I'm going to include both scale_factor and standard_parallel for now, and see if anything blows up later
crsT = fid.createVariable( 'crs_EASE2_T', 'S1', () )
crsT.long_name = "TBD"
crsT.grid_mapping_name = "lambert_cylindrical_equal_area"
crsT.longitude_of_projection_origin = 0.0
crsT.standard_parallel = 30.0
crsT.false_easting = 0.0
crsT.false_northing = 0.0
crsT.scale_factor_at_projection_origin = 0.0
crsT.proj4text = "+proj=laea +lat_0=90 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m"
crsT.srid = "urn:ogc:def:crs:EPSG::6931"
crsT.references = references
crsT.crs_wkt = "PROJCRS[\"WGS 84 / NSIDC EASE-Grid 2.0 Global\", BASEGEODCRS[\"WGS 84\", DATUM[\"World Geodetic System 1984\", ELLIPSOID[\"WGS 84\",6378137,298.257223563,LENGTHUNIT[\"metre\",1.0]]]], CONVERSION[\"US NSIDC EASE-Grid 2.0 Global\", METHOD[\"Lambert Cylindrical Equal Area\",ID[\"EPSG\",9835]], PARAMETER[\"Latitude of 1st standard parallel\",30,ANGLEUNIT[\"degree\",0.01745329252]], PARAMETER[\"Latitude of natural origin\",0,ANGLEUNIT[\"degree\",0.01745329252]], PARAMETER[\"Longitude of natural origin\",0,ANGLEUNIT[\"degree\",0.01745329252]], PARAMETER[\"False easting\",0,LENGTHUNIT[\"metre\",1.0]], PARAMETER[\"False northing\",0,LENGTHUNIT[\"metre\",1.0]]], CS[cartesian,2], AXIS[\"easting (X)\",east,ORDER[1]], AXIS[\"northing (Y)\",north,ORDER[2]], LENGTHUNIT[\"metre\",1.0], ID[\"EPSG\",6933]]"
In [ ]:
fid.close()
In [ ]:
%ls
In [ ]: