3
$\begingroup$

I have downloaded NetCDF data file EVE_L3_merged_1nm_2015323_005.ncdf from http://lasp.colorado.edu/eve/data_access/evewebdata/products/merged/ and read it by Mathematica 10.0.2 on my windows 7.

Import["D:\\...\\EVE_L3_merged_1nm_2015323_005.ncdf", "Elements"]

gives {"Annotations", "Data", "DataFormat", "Datasets", "Dimensions", "Metadata"}. the "Annotations", "DataFormat",names of "Datasets", "Dimensions", "Metadata" are all Imported correctly and

datsets =Import["D:\\...\\EVE_L3_merged_1nm_2015323_005.ncdf", "Datasets"];
Transpose@{Range@Length@datsets, datsets}

returns

{{1, "PRIMARY"}, {2, "PRIMARY_HEAD"}, {3, "LINESMETA_HEADER"}, {4, 
  "BANDSMETA_HEADER"}, {5, "DIODEMETA_HEADER"}, {6, 
  "SPECTRUMMETA_HEADER"}, {7, "MERGEDDATA_HEADER"}, {8, 
  "LINESMETA.WAVE_CENTER"}, {9, "LINESMETA.WAVE_MIN"}, {10, 
  "LINESMETA.WAVE_MAX"}, {11, "LINESMETA.LOGT"}, {12, 
  "LINESMETA.NAME"}, {13, "LINESMETA.TYPE"}, {14, 
  "LINESMETA.BLENDS"}, {15, "BANDSMETA.NAME"}, {16, 
  "BANDSMETA.TYPE"}, {17, "DIODEMETA.NAME"}, {18, 
  "DIODEMETA.TYPE"}, {19, "SPECTRUMMETA.WAVELENGTH"}, {20, 
  "SPECTRUMMETA.IRRADIANCE_UNITS"}, {21, "MERGEDDATA.YYYYDOY"}, {22, 
  "MERGEDDATA.CAPTURE"}, {23, "MERGEDDATA.SP_IRRADIANCE"}, {24, 
  "MERGEDDATA.SP_STDEV"}, {25, "MERGEDDATA.SP_PRECISION"}, {26, 
  "MERGEDDATA.SP_ACCURACY"}, {27, "MERGEDDATA.BAND_IRRADIANCE"}, {28, 
  "MERGEDDATA.BAND_STDEV"}, {29, "MERGEDDATA.BAND_PRECISION"}, {30, 
  "MERGEDDATA.BAND_ACCURACY"}, {31, 
  "MERGEDDATA.DIODE_IRRADIANCE"}, {32, "MERGEDDATA.DIODE_STDEV"}, {33,
   "MERGEDDATA.DIODE_PRECISION"}, {34, 
  "MERGEDDATA.DIODE_ACCURACY"}, {35, 
  "MERGEDDATA.LINE_IRRADIANCE"}, {36, "MERGEDDATA.LINE_STDEV"}, {37, 
  "MERGEDDATA.LINE_PRECISION"}, {38, "MERGEDDATA.LINE_ACCURACY"}, {39,
   "MERGEDDATA.AU_FACTOR"}}

notice that since 8th quantity the name of dataset contains "." by form "*.*"

If I Import the dataset whose name contains no "." by, for example,

Import["D:\\...\\EVE_L3_merged_1nm_2015323_005.ncdf", {"Datasets", "BANDSMETA_HEADER"}]

Import works well. However if I import dataset whose name contains "." by

Import["D:\\...\\EVE_L3_merged_1nm_2015323_005.ncdf",   {"Datasets", "MERGEDDATA.YYYYDOY"}]

Import broke and suggested

File does not contain a dataset "MERGEDDATA.YYYYDOY"

This problem is not confined to this particular file but occurs every time I Import NetCDF file with Datasets name including ".".

How could I Import data correctly?

$\endgroup$
1
  • $\begingroup$ this file is only 5MB in all. Mma can Import netcdf without "." in datasets name correctly as large as several hundred MB @JasonB $\endgroup$
    – Harry
    Nov 20, 2015 at 9:27

2 Answers 2

5
$\begingroup$

So, as we can see here

enter image description here

So if the dataset name contains one of those characters, it needs to be escaped. Try this, replacing "~/Downloads/" with "D:\...\" for the file

elementlist = 
 StringReplace[#, "." -> "\\."] & /@ 
  Import["~/Downloads/EVE_L3_merged_1nm_2015323_005.nc", "Datasets"]
(* {"PRIMARY", "PRIMARY_HEAD", "LINESMETA_HEADER", \
"BANDSMETA_HEADER", "DIODEMETA_HEADER", "SPECTRUMMETA_HEADER", \
"MERGEDDATA_HEADER", "LINESMETA\\.WAVE_CENTER", \
"LINESMETA\\.WAVE_MIN", "LINESMETA\\.WAVE_MAX", "LINESMETA\\.LOGT", \
"LINESMETA\\.NAME", "LINESMETA\\.TYPE", "LINESMETA\\.BLENDS", \
"BANDSMETA\\.NAME", "BANDSMETA\\.TYPE", "DIODEMETA\\.NAME", \
"DIODEMETA\\.TYPE", "SPECTRUMMETA\\.WAVELENGTH", \
"SPECTRUMMETA\\.IRRADIANCE_UNITS", "MERGEDDATA\\.YYYYDOY", \
"MERGEDDATA\\.CAPTURE", "MERGEDDATA\\.SP_IRRADIANCE", \
"MERGEDDATA\\.SP_STDEV", "MERGEDDATA\\.SP_PRECISION", \
"MERGEDDATA\\.SP_ACCURACY", "MERGEDDATA\\.BAND_IRRADIANCE", \
"MERGEDDATA\\.BAND_STDEV", "MERGEDDATA\\.BAND_PRECISION", "MERGEDDATA\
\\.BAND_ACCURACY", "MERGEDDATA\\.DIODE_IRRADIANCE", \
"MERGEDDATA\\.DIODE_STDEV", "MERGEDDATA\\.DIODE_PRECISION", \
"MERGEDDATA\\.DIODE_ACCURACY", "MERGEDDATA\\.LINE_IRRADIANCE", \
"MERGEDDATA\\.LINE_STDEV", "MERGEDDATA\\.LINE_PRECISION", "MERGEDDATA\
\\.LINE_ACCURACY", "MERGEDDATA\\.AU_FACTOR"} *)

data = Import[
     "~/Downloads/EVE_L3_merged_1nm_2015323_005.nc", {"Datasets", #}]& /@ elementlist;

and you can check that everything imported fine by

Dimensions /@ data
(* {{1}, {1, 5}, {1, 53}, {1, 28}, {1, 27}, {1, 47}, {1, 
  90}, {1, 39}, {1, 39}, {1, 39}, {1, 39}, {1, 39}, {1, 39}, {1, 
  39}, {1, 20}, {1, 20}, {1, 6}, {1, 6}, {1, 100}, {1}, {1, 2029}, {1,
   2029}, {1, 2029, 100}, {1, 2029, 100}, {1, 2029, 100}, {1, 2029, 
  100}, {1, 2029, 20}, {1, 2029, 20}, {1, 2029, 20}, {1, 2029, 
  20}, {1, 2029, 6}, {1, 2029, 6}, {1, 2029, 6}, {1, 2029, 6}, {1, 
  2029, 39}, {1, 2029, 39}, {1, 2029, 39}, {1, 2029, 39}, {1, 2029}} *)

This only works with periods, I wish there were a more robust way of treating the strings literally without escape characters, or a way of replacing them automatically. Like when you past some text into a string, it asks you if you want to escape the characters.

Anyway, this is a usable workaround for your problem.

$\endgroup$
1
$\begingroup$

The issue has been fixed in V13.0 and no workarounds are needed:

In[2]:= Import["EVE_L3_merged_1nm_2022095_007.ncdf","/MERGEDDATA.YYYYDOY"]

Out[2]= NumericArray[<1,4353>, Integer32]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.