How to open HDF4 file with xarray

1,341 views
Skip to first unread message

Uchida Takaya

unread,
Mar 10, 2016, 11:56:43 AM3/10/16
to xarray
To whom it may concern,

I am currently trying to read in a MODIS daily sea-surface temperature data in HDF4 format using xarray. A link to a sample data file is: ftp://podaac-ftp.jpl.nasa.gov/allData/modis/L3/aqua/11um/4km/daily/2003/001/A2003001.L3m_DAY_NSST_4.bz2

I have tried netCDF4 engine and pynio engine and none of them work. The codes that I have tried are:

fname = os.path.join('A2003001.L3m_DAY_NSST_4')
nc = xray.open_dataset(fname)

and the error I get is:

RuntimeError: NetCDF: Unknown file format

If I try using the netCDF4 engine as:

nc = xray.open_dataset(fname, engine='pynio')

I get the error:

NIOError: Unable to open file

Could you please show me how to get around this issue?

Sincerely,
Takaya Uchida

Stephan Hoyer

unread,
Mar 12, 2016, 5:25:13 PM3/12/16
to xar...@googlegroups.com
Hi Takaya,

It looks like PyNIO (and hence xarray) can open this file if you rename it to have a ".h4" extension:

In [5]: mv /Users/Stephan/Downloads/A2003001.L3m_DAY_NSST_4/Users/Stephan/Downloads/A2003001.L3m_DAY_NSST_4.h4

In [6]: xr.open_dataset('/Users/Stephan/Downloads/A2003001.L3m_DAY_NSST_4.h4', engine='pynio')
Out[6]:
<xarray.Dataset>
Dimensions:   (fakeDim0: 4320, fakeDim1: 8640, fakeDim2: 4320, fakeDim3: 8640)
Coordinates:
  * fakeDim0  (fakeDim0) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...
  * fakeDim1  (fakeDim1) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...
  * fakeDim2  (fakeDim2) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...
  * fakeDim3  (fakeDim3) int64 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...
Data variables:
    l3m_qual  (fakeDim2, fakeDim3) uint8 255 255 255 255 255 255 255 255 255 ...
    l3m_data  (fakeDim0, fakeDim1) uint16 65535 65535 65535 65535 65535 ...
Attributes:
    Latitude_Step: [ 0.04166667]
    Start_Year: [2002]
    Map_Projection: Equidistant Cylindrical
    Title: MODISA Level-3 Standard Mapped Image
    SW_Point_Latitude: [-89.97916412]
    Start_Time: 2002365123005000
    Start_Day: [365]
    Mission:
    Easternmost_Longitude: [ 180.]
    Longitude_Units: degrees East
    Units: deg-C
    Scaled_Data_Maximum: [ 45.]
    Station_Name:
    Sensor:
    Input_Files: A2003001.L3b_DAY_NSST.main
    Period_Start_Day: [1]
    Number_of_Lines: [4320]
    Sensor_Name: MODISA
    Period_End_Year: [2003]
    Scaled_Data_Minimum: [-2.]
    End_Year: [2003]
    Longitude_Step: [ 0.04166667]
    L2_Flag_Names: LAND,~HISOLZ
    End_Millisec: [8704000]
    Processing_Time: 2006068023708000
    Intercept: [-2.]
    Product_Name: A2003001.L3m_DAY_NSST_4
    Scaling: linear
    Software_Name: smigen
    Software_Version: 3.30
    Processing_Control: smigen par=A2003001.L3m_DAY_NSST_4.param
    Period_End_Day: [1]
    Parameter: Sea Surface Temperature
    Orbit: [0]
    Mission_Characteristics:
    SW_Point_Longitude: [-179.97917175]
    Start_Orbit: [0]
    Station_Latitude: [ 0.]
    Data_Bins: [4241743]
    Data_Center:
    Product_Type: D
    Scaling_Equation: (Slope*l3m_data) + Intercept = Parameter value
    Input_Parameters: IFILE = /data1/vdc/sdpsoper/vpu0/workbuf/A2003001.L3b_DAY_NSST.main|OFILE = A2003001.L3m_DAY_NSST_4|PFILE = |PROD = sst|PALFILE = DEFAULT|RFLAG = ORIGINAL|MEAS = 1|STYPE = 0|DATAMIN = 0.000000|DATAMAX = 0.000000|LONWEST = -180.000000|LONEAST = 180.000000|LATSOUTH = -90.000000|LATNORTH = 90.000000|RESOLUTION = 4km|PROJECTION = RECT|GAP_FILL = 0|SEAM_LON = -180.000000|PRECISION = |
    Start_Millisec: [45005000]
    Slope: [ 0.00071718]
    Southernmost_Latitude: [-90.]
    End_Orbit: [0]
    Period_Start_Year: [2003]
    Replacement_Flag: ORIGINAL
    Data_Maximum: [ 34.93000031]
    Number_of_Columns: [8640]
    Latitude_Units: degrees North
    Station_Longitude: [ 0.]
    Data_Minimum: [-1.99999905]
    Northernmost_Latitude: [ 90.]
    Westernmost_Longitude: [-180.]
    End_Time: 2003002022504000
    Measure: Mean
    End_Day: [2]
    Sensor_Characteristics:

Cheers,
Stephan

--
You received this message because you are subscribed to the Google Groups "xarray" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xarray+un...@googlegroups.com.
To post to this group, send email to xar...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xarray/6a330d25-1b24-41a7-bada-e8cb4ae465a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages