[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 950307: declaration-start-count questions
- Subject: Re: 950307: declaration-start-count questions
- Date: Wed, 08 Mar 1995 09:27:51 -0700
>Organization: CSU
>Keywords: 199503072249.AA18945
Hi Doug,
> These are probably very basic questions, but I cannot seem to get them
> straight...
>
> First, here's a bit of the header of the netCDF file I'm trying to read:
>
> - -=<2>=- ncdump acf94095.nc
> netcdf acf94095 {
> dimensions:
> latitude = 3 ;
> longitude = 3 ;
> level = 4 ;
> view = 2 ;
> time = UNLIMITED ; // (21 currently)
>
> variables:
> long Base_Time ;
> Base_Time:string = "0:00:00 GMT 05 April 1994 " ;
> Base_Time:long_name = "base time in epoch" ;
> Base_Time:units = "seconds since 0:00:00 GMT 01 January 1970"
>
> ;
> double Time_Offset(time) ;
> Time_Offset:long_name = "time offset from base time" ;
> Time_Offset:units = "seconds" ;
> float Latitude(latitude) ;
> Latitude:valid_range = -90.f, 90.f ;
> Latitude:long_name = "north latitude" ;
> Latitude:units = "degrees" ;
It would be better to follow convention and name this variable "latitude"
instead of "Latitude". If a variable has exactly the same name as a
dimension, programs written to import netCDF data will recognize it as a
coordinate variable, giving the coordinate values for the corresponding
dimension. For example, "ncdump -c afc.nc" shows the names of all
dimensions, variables, and attributes, and the values of coordinate
variables for the file "afc.nc", if it uses this convention.
Similarly, the variables Longitude, Level, and View cannot be recognized as
coordinate variables unless they have exactly the same name as the
corresponding dimensions.
This is just a side remark, however; it is unrelated to the questions you
are asking below.
> float Longitude(longitude) ;
> Longitude:valid_range = -180.f, 180.f ;
> Longitude:long_name = "east longitude" ;
> Longitude:units = "degrees" ;
> float Level(level) ;
> Level:valid_range = 1.f, 4.f ;
> Level:long_name = "cloud level" ;
> Level:units = "unitless" ;
> Level:value_1 = "A value of 1. corresponds to low clouds." ;
> Level:value_2 = "A value of 2. corresponds to mid clouds." ;
> Level:value_3 = "A value of 3. corresponds to high clouds." ;
> Level:value_4 = "A value of 4. corresponds to all clouds." ;
> float View(view) ;
> View:valid_range = 1.f, 2.f ;
> View:long_name = "scene description" ;
> View:units = "unitless" ;
> View:value_1 = "A value of 1. corresponds to a clear scene." ;
> View:value_2 = "A value of 2. corresponds to the total
> scene."
>
> ;
> float Cloud_Amount(time, level, latitude, longitude) ;
> Cloud_Amount:valid_range = 0.f, 100.f ;
> Cloud_Amount:_FillValue = -888.f ;
> Cloud_Amount:missing_value = -999.f ;
> Cloud_Amount:long_name = "cloud amount" ;
> Cloud_Amount:units = "percent cloudy" ;
> float Clear_Temperature(time, latitude, longitude) ;
> Clear_Temperature:valid_range = 160.f, 330.f ;
> Clear_Temperature:_FillValue = -888.f ;
> Clear_Temperature:missing_value = -999.f ;
> Clear_Temperature:long_name = "clear IR temperature" ;
> Clear_Temperature:units = "Kelvin" ;
> ...
>
> Now for the questions:
>
> When using the fortran subroutine NCVGT, my understanding is that the
> variable whose hyperslab you wish to read from an existing netCDF file must
> be declared in the program with arrays having the size of the dimensions (as
> defined in the netCDF file) in DESCENDING order, with the unlimited
> dimension being last.
Yes, the FORTRAN dimension order is the opposite of the C dimension order,
and the C order is what is used in CDL declarations.
> Thus, I should declare Cloud_Amount as (assuming the integer size of
> level,lat,lon,time have been declared in a parameter statement):
>
> real clamt(level,lat,lon,time)
No, it should be declared with all the dimensions in the opposite order to
the CDL declaration:
real clamt(lon,lat,level,time)
> However, both start and count correspond to the variable's dimensions (as
> defined) in the netCDF file. Thus, if I want to start at the very beginning
> of the hyperslab, I set
>
> data start /1,1,1,1/
> data count /time,level,lat,lon/
No, start is OK, but set count to correspond to the order of dimensions in
the declaration:
data count /lon,lat,level,time/
> Now for the next question. Since there are a total of 5 dimensions in the
> netCDF file, do I have to declare ndims=5 (and start, count accordingly),
> even though Cloud_Amount itself only has 4 dimensions?
No, start and count only to need to be declared as large as necessary for
their use in any call. In your example, declaring them to have size 4 will
work fine.
> Thus far, I've set
> ndims=4 which seems to work, but maybe this is why I'm having the problem
> explained above. Also, relating to this question, what do I do about
> reading variables in the same fortran program with mixed numbers of
> dimensions, in terms of setting ndims, start and count? For example, what
> if I wanted to also read the hyperslab of Clear_Temperature along with that
> of Cloud_Amount in the same program, but which has a different number of
> dimensions from Cloud_Amount?
To read Clear_Temperature, which has 3 dimensions, you can either reuse the
start and count variables you have (only the first 3 values of start and
count will be used in this case, so it doesn't mater what start(4) and
count(4) are), or you can use different start and count arrays that are
dimensioned for only 3. You might want to do the latter if you are
alternately reading from a 4-dimensional and a 3-dimensional variable in a
loop, because it would be easier to just update the start vector and leave
the count vector constant between calls to NCVGT when getting time slices
from both variables for example.
> Last question:
>
> Below is an ncdump sample of the actual data, which I've modified slightly
> to show my interpretation of the way the data in Cloud_Amount is actually
> arranged. Is this correct? ...
>
> Latitude = 36.90999985, 36.61000061, 36.31000137 ;
>
> Longitude = -97.79000092, -97.48999786, -97.19000244 ;
>
> Level = 1, 2, 3, 4 ;
>
> View = 1, 2 ;
>
> Cloud_Amount =
> l l l
> a a a
> t t t
> 1 2 3
>
> | | | _____________________________
> lon1-> 0, 0, 0, | |
> lon2-> 0, 0, 0, | level 1 |
> lon3-> 0, 0, 0, ________________|_ |
>
> 38.56999969, 84.05999756, 100, | |
> 76.19000244, 100, 100, | level 2 |
> 100, 100, 100, _|_ | time 1
> 61.43000031, 15.93999958, 0, | |
> 23.80999947, 0, 0, | level 3 |
> 0, 0, 0, _|_ |
> 100, 100, 100, | |
> 100, 100, 100, | level 4 |
> 100, 100, 100, ________________|___________|_
> 0, 0, 0, |
> 0, 0, 0, |
> 0, 0, 0, |
> 90.16000366, 100, 100, |
> 55.74000168, 100, 100, |
> 98.36000061, 100, 100, |
> 9.84000015, 0, 0, | time 2
> 44.25999832, 0, 0, |
> 1.63999999, 0, 0, |
> 100, 100, 100, |
> 100, 100, 100, |
> 100, 100, 100,_____________________________|_
>
> ...etc...
>
> Thanks very much for whatever light you can shed,
No, according to your CDL declaration, time varies most slowly, then level,
then latitude, then longitude varying fastest, so it looks like you've got
lat and lon reversed in the above.
One way to check the order is by using the "-b fortran" or "-f fortran"
options to ncdump, which will show you (in comment annotations) the indices
for each data value. See the ncdump man page for details.
______________________________________________________________________________
Russ Rew UCAR Unidata Program
address@hidden P.O. Box 3000
http://www.unidata.ucar.edu/ Boulder, CO 80307-3000
______________________________________________________________________________