; Copyright (C) 2019 The HDF Group ; All rights reserved. ; ; This example code illustrates how to access and visualize ; LP DAAC MCD19A2 HDF-EOS2 Sinusoidal Grid file using NCL. ; ; If you have any questions, suggestions, comments on this example, ; please use the HDF-EOS Forum (http://hdfeos.org/forums). ; ; If you would like to see an example of any other NASA HDF/HDF-EOS data ; product that is not listed in the HDF-EOS Comprehensive Examples page ; (http://hdfeos.org/zoo), feel free to contact us at eoshelp@hdfgroup.org ; or post it at the HDF-EOS Forum (http://hdfeos.org/forums). ; ; ; Usage:save this script and run ; ; $ncl MCD19A2.A2010010.h25v06.006.2018047103710.hdf.ncl ; ; Tested under: NCL 6.6.2 ; Last Updated: 2019-05-23 begin ; creating a new array to place numerous days/months/years together twoday_data = new((/1753,1200,1200/),"double") ; listing of all HDF files in a directory ; ls *.hdf > MODISLIST.txt ifiles = "MCD19A2.A2002152.h12v04.006.2018017002927.pscs_000501348964.hdf" ; file_name = systemfunc ("ls MCD19A2.A2019120.h12v04.006.2019122083552.hdf") ; file paths ; ifiles = systemfunc ("ls MCD19A2.A2002*.hdf") ; file paths ifile = addfile(ifiles(t), "r") ; print(ifile) ; Read file as HDF-EOS2 file to obtain lat and lon. ; he2_file = addfile(file_name + ".he2", "r") he2_file = addfile(ifiles(t) + ".he2", "r") ; Read a specific variable. data_raw = he2_file->Optical_Depth_047_grid1km ; Copy attributes. data@long_name = data_raw@long_name data@units = data_raw@unit ; Associate longitude and latitude. data@lat2d = he2_file->GridLat_grid1km data@lon2d = he2_file->GridLon_grid1km ; create AOD extraction file for a given location data_raw1 = data_raw(0,{40.821},{-73.949}) asciiwrite("test.txt",data_raw1)