[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20010501: How to get netcdf text info



Celia,

The dcacars decoder in GEMPAK extracts these airport ID fields.
You may want to look at that code in 
$NAWIPS/unidata/ldmbridge/dcacars/decode_ncacars.c
since it is already written.

Here is the relevant code section, the aid_len and rpt_len come
from dimention inquiries of the attributes:


   memset(orig,'\0',sizeof(orig));
   memset(dest,'\0',sizeof(dest));
   vc[1] = aid_len;
   ier = nc_get_vara_text(cdfid,orig_id,var_i,vc,orig);
   ier = nc_get_vara_text(cdfid,dest_id,var_i,vc,dest);
   memset(rptsta,'\0',sizeof(rptsta));
   vc[1] = rpt_len;
   ier = nc_get_vara_text(cdfid,rpt_id,var_i,vc,rptsta);

Steve Chiswell
Unidata User Support

>From: Celia Chen <address@hidden>
>Organization: UCAR/Unidata
>Keywords: 200105012302.f41N2Bp29284

>
>I need some help getting text formatted data off an netcdf file
>(see the attached header). For example, I would like to get 
>rptStation, origAirport, and destAirport and store them in
>arrays.  I have tried nc_get_var_text without success - 
>I was getting seg fault error at run time.  
>
>Please advise.
>
>Celia
>
>
>======================
>netcdf 20011211540 {
>dimensions:
>       recNum = UNLIMITED ; // (3367 currently)
>       enLen = 12 ;
>       rptStationLen = 4 ;
>       AirportIdLen = 6 ;
>       dateLen = 30 ;
>variables:
>       int missingInputMinutes ;
>               missingInputMinutes:long_name = "missing minutes of input data"
>  ;
>               missingInputMinutes:units = "minutes" ;
>       char minDate(dateLen) ;
>               minDate:long_name = "minimum observation date" ;
>               minDate:units = "human-readable min date/time" ;
>       char maxDate(dateLen) ;
>               maxDate:long_name = "maximum observation date" ;
>               maxDate:units = "human-readable max date/time" ;
>       double minSecs ;
>               minSecs:long_name = "minimum observation time" ;
>               minSecs:units = "seconds since 1970-1-1 00:00:00" ;
>       double maxSecs ;
>               maxSecs:long_name = "maximum observation time" ;
>               maxSecs:units = "seconds since 1970-1-1 00:00:00" ;
>       float latitude(recNum) ;
>               latitude:units = "degree_N" ;
>               latitude:valid_range = 0.f, 90.f ;
>               latitude:_FillValue = 99999.f ;
>       float longitude(recNum) ;
>               longitude:units = "degree_E" ;
>               longitude:valid_range = -180.f, 180.f ;
>               longitude:_FillValue = 99999.f ;
>       float altitude(recNum) ;
>               altitude:units = "meter (pressure altitude, msl)" ;
>               altitude:_FillValue = 99999.f ;
>               altitude:valid_min = -100.f ;
>       double timeObs(recNum) ;
>               timeObs:long_name = "time of observation" ;
>               timeObs:units = "seconds since 1970-1-1 00:00:00" ;
>               timeObs:_FillValue = 0. ;
>       float temperature(recNum) ;
>               temperature:units = "Kelvin" ;
>               temperature:_FillValue = 99999.f ;
>       float windDir(recNum) ;
>               windDir:long_name = "Wind Direction" ;
>               windDir:units = "degree_true" ;
>               windDir:_FillValue = 99999.f ;
>               windDir:valid_range = 0.f, 359.99f ;
>       float windSpeed(recNum) ;
>               windSpeed:long_name = "Wind Speed" ;
>               windSpeed:units = "meter/sec" ;
>               windSpeed:_FillValue = 99999.f ;
>               windSpeed:valid_min = 0.f ;
>       float heading(recNum) ;
>               heading:long_name = "heading of flight path over ground" ;
>               heading:units = "degree_true" ;
>               heading:_FillValue = 99999.f ;
>               heading:valid_range = 0.f, 359.99f ;
>       float mach(recNum) ;
>               mach:long_name = "mach number (0-1)" ;
>       float waterVaporMR(recNum) ;
>               waterVaporMR:long_name = "downlinked water vapor mixing ratio" 
> ;
>               waterVaporMR:units = "none" ;
>               waterVaporMR:_FillValue = -1.f ;
>       float correctedWVMR(recNum) ;
>               correctedWVMR:long_name = "corrected water vapor mixing ratio" 
> ;
>               correctedWVMR:units = "none" ;
>               correctedWVMR:_FillValue = -1.f ;
>       float downlinkedRH(recNum) ;
>               downlinkedRH:long_name = "downlinked relative humidity" ;
>               downlinkedRH:units = "none" ;
>               downlinkedRH:_FillValue = -1.f ;
>       float dewpoint(recNum) ;
>               dewpoint:long_name = "Dew Point (Kelvin)" ;
>               dewpoint:units = "Kelvin" ;
>               dewpoint:_FillValue = 99999.f ;
>       float rh_probe(recNum) ;
>               rh_probe:long_name = "RH in probe (0-1), w/ Vaisala correction 
> un-done" ;
>               rh_probe:_FillValue = 0.f ;
>       float medTurbulence(recNum) ;
>               medTurbulence:long_name = "Median eddy dissipation rate" ;
>               medTurbulence:units = "m^(2/3) s^-1" ;
>               medTurbulence:_FillValue = -9.99f ;
>       float maxTurbulence(recNum) ;
>               maxTurbulence:long_name = "Maximum eddy dissipation rate" ;
>               maxTurbulence:units = "m^(2/3) s^-1" ;
>               maxTurbulence:_FillValue = -9.99f ;
>       float vertAccel(recNum) ;
>               vertAccel:long_name = "peak vertical acceleration" ;
>               vertAccel:units = "meters/sec/sec" ;
>               vertAccel:valid_range = -99.9, 99.9 ;
>               vertAccel:_FillValue = 99999.f ;
>       float vertGust(recNum) ;
>               vertGust:long_name = "peak vertical gust" ;
>               vertGust:units = "meters/sec" ;
>               vertGust:_FillValue = 99999.f ;
>       char en_tailNumber(recNum, enLen) ;
>               en_tailNumber:long_name = "FSL-encrypted tail number" ;
>       byte dataDescriptor(recNum) ;
>               dataDescriptor:long_name = "AWIPS-type data descriptor" ;
>               dataDescriptor:units = "  good= R  or  T , bad= X" ;
>       byte errorType(recNum) ;
>               errorType:units = "  temp=T, wind=W, both=B " ;
>       byte rollFlag(recNum) ;
>               rollFlag:long_name = "Aircraft roll angle flag " ;
>               rollFlag:units = "  G = < 5 degrees, B = > 5 degrees" ;
>       byte waterVaporQC(recNum) ;
>               waterVaporQC:long_name = "water vapor mixing ratio QC character
> " ;
>               waterVaporQC:value_0 = "Normal, Ground speed > 60 knots." ;
>               waterVaporQC:value_1 = "Normal, nonmeasurement mode, Ground spe
> ed < 60 knots" ;
>               waterVaporQC:value_2 = "Small RH, RH measured is < 1.5%;RH set 
> to 1.5%" ;
>               waterVaporQC:value_3 = "Humidity element wet. RH = 5.0v for < 1
> 20s" ;
>               waterVaporQC:value_4 = "Element contatminated. RH=5v for>120s" 
> ;
>               waterVaporQC:value_5 = "Heater fail" ;
>               waterVaporQC:value_6 = "Heater fail and wet/contatminated eleme
> nt" ;
>               waterVaporQC:value_7 = "1 or more inputs invalid" ;
>               waterVaporQC:value_8 = "Numeric error" ;
>               waterVaporQC:value_9 = "Dew point greater than temperature" ;
>       byte interpolatedTime(recNum) ;
>               interpolatedTime:long_name = "UPS ascent/descent time interpola
> tion indicator" ;
>               interpolatedTime:units = "r for raw data, i for interpolated" ;
>       byte interpolatedLL(recNum) ;
>               interpolatedLL:long_name = "UPS ascent/descent lat&lon interpol
> ation indicator" ;
>               interpolatedLL:units = "r for raw data, i for interpolated" ;
>       byte tempError(recNum) ;
>               tempError:units = "good= p ,bad= W  or  C ,unknown= -" ;
>       byte windDirError(recNum) ;
>               windDirError:units = " good= p ,bad= B ,unknown= -" ;
>       byte windSpeedError(recNum) ;
>               windSpeedError:units = "  good= p ,bad= F  or  S ,unknown= -" ;
>       byte speedError(recNum) ;
>               speedError:long_name = "Aircraft ground speed error" ;
>               speedError:units = "  good= p ,bad= F  or  S ,unknown= -" ;
>       byte bounceError(recNum) ;
>               bounceError:long_name = "Aircraft altitude variance error" ;
>               bounceError:units = "good= p ,bad= H  or  L ,unknown= -" ;
>       byte correctedFlag(recNum) ;
>               correctedFlag:long_name = "Corrected data indicator" ;
>               correctedFlag:units = "r,l,T,f,or t" ;
>               correctedFlag:value_r = "raw data" ;
>               correctedFlag:value_l = "lat/lon correction (other than interpo
> lation)" ;
>               correctedFlag:value_T = "temperature correction" ;
>               correctedFlag:value_f = "longitude and wind direction flipped" 
> ;
>               correctedFlag:value_t = "obs time has been set to the report re
> ceipt time" ;
>       char rptStation(recNum, rptStationLen) ;
>               rptStation:long_name = "Station reporting through" ;
>               rptStation:_FillValue = " " ;
>       double timeReceived(recNum) ;
>               timeReceived:long_name = "time data was received at ground stat
> ion" ;
>               timeReceived:units = "seconds since 1970-1-1 00:00:00" ;
>               timeReceived:_FillValue = 0. ;
>       char origAirport(recNum, AirportIdLen) ;
>               origAirport:long_name = "Originating Airport" ;
>               origAirport:valueUNKN = "   " ;
>               origAirport:FillValue = "   " ;
>       char destAirport(recNum, AirportIdLen) ;
>               destAirport:long_name = "Destination Airport" ;
>               destAirport:valueUNKN = "   " ;
>               destAirport:FillValue = "   " ;
>
>// global attributes:
>               :title = "ACARS data, encrypted tail numbers" ;
>               :reference = "FSL encrypted ACARS, 14-Nov-2000" ;
>               :version = "2.6" ;
>data:
>
> missingInputMinutes = 0 ;
>
> minDate = "Tue 01-May-2001 1440:00 UTC" ;
>
> maxDate = "Tue 01-May-2001 1534:43 UTC" ;
>
> minSecs = 988728000 ;
>
> maxSecs = 988731283 ;
>
> latitude = -6.233333, -7.083333, 52.55, 52.55, 52.55, 52.56667, 52.56667, 
>-- 
>Celia Chen
>RAP/NCAR
>
>"Nothing is as strong as gentleness or as gentle as strength."
>                                       - Dove Milk Promises
>
>