[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDF #QAK-764753]: Variables with different dimensions
- Subject: [netCDF #QAK-764753]: Variables with different dimensions
- Date: Mon, 26 Mar 2018 11:55:36 -0600
I think I begin to see the issue.
First, let me point out that if you
have an unlimited whose max size is 365,
this does not mean that 365 dimension points are stored
in the file. In the cases where you are only
using 2 points, only those two points will be stored
even if 365 points are stored for some other variable.
So, you should not have to worry about the space involved.
Second, IMO you are abusing the word "time". You actually
have two time dimensions: one for annual data and one for daily data.
The best solution is to have two actual time dimensions.
If you choose to use only one time dimension, then I think your
only solution is to add attributes to the variables that indicate
if the time for that variable is annual or daily.
You also have the problem for the annual data of which dimension
point to use: time=0 and time=364 or time=0 and time=1, or what?
> I have multiple variables as model arrays but assume for the example its 4.
>
> Temperature which has three spatial dimensions x,y,z
>
> Precipitation which has two spatial dimensions x,y
>
> Albedo which has two spatial dimensions x,y
>
> Density which has three spatial dimensions x,y,z
>
> I want to write those in netcdf files, with different time resolutions
> depending on the users choice.
>
> So what I want now is to write temperature and precipitation daily but
> albedo and density only annually.
>
> So the 4 variables should have following dimensions: x,y,z,t1(365), x,y,
> t1(365), x,y,t2(1), x,y,z,t2(1).
>
> I had defined t as the unlimited axes, but that leads to 365 entries
> also for the variables which are only writte two once. It would really
> help if I see an easy example to implement somthing above. What I in the
> end want is: All my variables have fixed spatial dimensions, so for
> example temperature is always x,y,z. But I can have a switch for each of
> them which determines at which temporal resolution its written. So that
> I only have to change 1 input parameter per variable which makes it
> either write daily, monthly, yearly. Alternatively writing them in
> seperarte files for the different time steps
>
> One workaround would be to create 6 net cdf files, with xyz1, xyz12,
> xyz365, xy1,xy12, xy365 representing spatial 2/3D and daily, monthly
> and yearly data and use if statements within the initialisation and
> writing of the netcdf every year if the variable should be written or
> not. But i think netcdf can be much better.
>
>
> regards
> tobias
> A, m 25.03.2018 um 19:48 schrieb Unidata netCDF Support:
> > I am afraid I do not understand your explanation.
> > Can you give me several concrete examples of what you
> > want to represent?
> >
> > In any case, since you are using netcdf-4, you can declare
> > x,y, and time to all be unlimited. Would that solve your problem?
> >
> >>
> >> I am using netcdf-4.
> >>
> >> The problem if i have 5variables all defined on x,y and time, which is
> >> the unlimited axes. If one of them has a different dimension on the time
> >> axis (say 365 as daily data) all the other variables also have a length
> >> of 365 in the time dimension (which takes a lot of storage, despite no
> >> real values written in all except the first one)
> >>
> >> What I would really want is to save data that is either 2 or 3D with
> >> different time resolutions. So depending on the end-user choice all
> >> variables can either be x,y,(z) with annual, daily or monthly
> >> resolution. So the length of the time dimension is varying. Either save
> >> all 3D values with different time resolutions in one file or all with
> >> the same temporal resolution, allowing for different dimensions of the
> >> variables 2+time or 3+time.
> >>
> >> using fortran
> >>
> >> regards
> >>
> >> tobias
> >>
> >>
> >> Am 23.03.2018 um 19:40 schrieb Unidata netCDF Support:
> >>> Using time as an unlimited dimension seems the correct approach.
> >>> If you plan to use netcdf-3, then the time dimension needs to be
> >>> the first dimension. So something like this.
> >>>
> >>> netcdf example {
> >>> dimensions:
> >>> time = unlimited;
> >>> x = ...;
> >>> y = ...;
> >>>
> >>> variables:
> >>> float v1(time,x,y);
> >>> float v2(time,x,y)
> >>> }
> >>>
> >>> If you instead plan to use netcdf-4, then the unlimited time
> >>> dimension does not need to be the first; it can be in any position.
> >>>
> >>>
> >>>> I would like to create a netcdf file with multiple variables which use
> >>>> different dimensions:
> >>>>
> >>>> 6 variables all defined with x,y and time, but for one the length of the
> >>>> time dimension should be 365 and once 1 (annual and daily data). I
> >>>> thought about defining 4 variables with
> >>>>
> >>>> x,y, time and time2
> >>>>
> >>>> How do you do this i seem to fail all the time with it?
> >>>>
> >>>> (the main errros: Error: NetCDF: Invalid dimension ID or name / Error:
> >>>> NetCDF: NC_UNLIMITED in the wrong index / Error: NetCDF: One or more
> >>>> variable sizes violate format constraints )
> >>>>
> >>>> another example: I want to have 3 variables which are defined on the x,y
> >>>> and time dimension and a 4th one which also has a x,y,z and time
> >>>>
> >>>> time is the unlimited dimension. I can define those for separate files
> >>>> and save them but are there any example scripts available for variables
> >>>> in a single file which have different dimensions?
> >>>>
> >>>>
> >>>> regards
> >>>>
> >>>>
> >>>> tobias zolles
> >>>>
> >>>>
> >>> =Dennis Heimbigner
> >>> Unidata
> >>>
> >>>
> >>> Ticket Details
> >>> ===================
> >>> Ticket ID: QAK-764753
> >>> Department: Support netCDF
> >>> Priority: Normal
> >>> Status: Open
> >>> ===================
> >>> NOTE: All email exchanges with Unidata User Support are recorded in the
> >>> Unidata inquiry tracking system and then made publicly available through
> >>> the web. If you do not want to have your interactions made available in
> >>> this way, you must let us know in each email you send to us.
> >>>
> >>>
> >>
> > =Dennis Heimbigner
> > Unidata
> >
> >
> > Ticket Details
> > ===================
> > Ticket ID: QAK-764753
> > Department: Support netCDF
> > Priority: Normal
> > Status: Open
> > ===================
> > NOTE: All email exchanges with Unidata User Support are recorded in the
> > Unidata inquiry tracking system and then made publicly available through
> > the web. If you do not want to have your interactions made available in
> > this way, you must let us know in each email you send to us.
> >
> >
>
>
=Dennis Heimbigner
Unidata
Ticket Details
===================
Ticket ID: QAK-764753
Department: Support netCDF
Priority: Normal
Status: Open
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata
inquiry tracking system and then made publicly available through the web. If
you do not want to have your interactions made available in this way, you must
let us know in each email you send to us.