[ncl-talk] Multiple_Timeser_annavg_O3CONOX
Rick Brownrigg
brownrig at ucar.edu
Fri Jun 10 14:35:52 MDT 2022
Hi,
In your original script, you had something like this:
plot0 = gsn_csm_xy (wks,var_ann&lat,data(0,:,:),res)
data(0,:,:) is a slice into a 3D variable, and thus a 2D variable. Plotting
latitude vs. a 2D field doesn't make sense for an XY plot. Do you want a
contour plot instead? Or somehow you'll need to reduce data(0,:,:) to a
1D variable.
Rick
On Fri, Jun 10, 2022 at 5:06 AM Najib Yusuf <najibgal at yahoo.com> wrote:
> Hi Rick,
>
> Thank you for your help. It is so muddled for me. Now I got another error
> even though var_ann_flip and data both have 3 dimensions but leftmost
> dimension size is not same. How can I take care of this please. Thank you
> (0) gsn_csm_xy: Fatal: X and Y must have the same dimensions sizes, or
> one must be one-dimensional and both have the same rightmost dimension.
>
>
> Variable: var_ann_flip
> Type: float
> Total Size: 12386304 bytes
> 3096576 values
> Number of Dimensions: 3
> Dimensions and sizes: [lev | 56] x [lat | 192] x [lon | 288]
> Coordinates:
> lev: [1.867879997007549..992.5000106104562]
> lat: [ -90.. 90]
> lon: [-180..178.75]
> Number Of Attributes: 6
> cell_methods : time: mean
> long_name : O3 concentration
> units : mol/mol
> mdims : 1
> average_op_ncl : dim_avg_n over dimension(s): time
> lonFlip : longitude coordinate variable has been reordered via
> lonFlip
>
> Variable: data
> Type: float
> Total Size: 663552 bytes
> 165888 values
> Number of Dimensions: 3
> Dimensions and sizes: [3] x [192] x [288]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : 9.96921e+36
>
> Variable: data (subsection)
> Type: float
> Total Size: 221184 bytes
> 55296 values
> Number of Dimensions: 2
> Dimensions and sizes: [lat | 192] x [lon | 288]
> Coordinates:
> lat: [ -90.. 90]
> lon: [-180..178.75]
> Number Of Attributes: 8
> lev : 992.5000106104562
> _FillValue : 9.96921e+36
> cell_methods : time: mean
> long_name : O3 concentration
> units : mol/mol
> mdims : 1
> average_op_ncl : dim_avg_n over dimension(s): time
> lonFlip : longitude coordinate variable has been reordered via
> lonFlip
> (0) gsn_csm_xy: Fatal: X and Y must have the same dimensions sizes, or
> one must be one-dimensional and both have the same rightmost dimension.
>
>
>
> *------------------------------------*
> *Najib Yusuf Galadanci PhD*
> *Assistant Director (R & D)*
>
> *Lower Atmospheric Dynamics(Aerosol radiative forcing, air quality
> observations and modeling)Centre for Atmospheric ResearchNational Space
> Research and Development Agency. Kogi StateUniversity Campus, Anyigba. Kogi
> State. Nigeria+234 80 3871 4158------------------------------------Know
> that Victory comes with Patience, Relief with Affliction, and Ease with
> Hardship.Prophet Muhammad Rasulullah (PBUH) *
>
>
>
> On Thursday, June 9, 2022, 05:11:51 PM GMT+1, Rick Brownrigg <
> brownrig at ucar.edu> wrote:
>
>
> Hi Najib,
>
> OK, I see now that each time through the loop, a different variable is
> pulled from the files into the variable "var", from which the variable
> "var_ann_flip" gets constructed. If so, then these statements don't make
> sense:
>
> data(0,:) = var_ann_flip(55,:,:)
> data(1,:) = var_ann_flip(55,:,:)
> data(2,:) = var_ann_flip(55,:,:)
>
> each time through the loop, all three data 0..2 get overwritten by the
> same "var". You probably want something like:
>
> data(i,:,:) = var_ann_flip(55,:,:)
>
> But that mean the plotting is wrong too; rather than trying to plot all
> three plots *each time through the loop*, you probably want to generate
> just one:
>
> plot = gsn_csm_xy (wks,var_ann&lat,data(i,:,:),res)
>
> This all has implications for labelling and colors -- they too should
> likely be based off of indexing into an arrays of labels/colors based upon
> "i".
>
> The logic is kind of muddled. Try to think about what needs to change each
> time through the loop and what values/variables you have in hand at each
> iteration.
>
> Hope that helps...
> Rick
>
>
>
> On Thu, Jun 9, 2022 at 8:54 AM Najib Yusuf <najibgal at yahoo.com> wrote:
>
>
> *Hi Rick again,*
>
> *I am trying to plot annual average of O3, CO and NOX this is what I
> wanted to represented with this variable 0,1,2.*
>
>
>
> * data(0,:,:) data(1,:,:) data(2,:,:)*
>
> *all the three variables are surface level 55. *
>
> *So my annual average is var_ann_flip, I thought to represent each
> variable as *
>
>
>
> * data(0,:,:) = var_ann_flip(55,:,:) data(1,:,:) =
> var_ann_flip(55,:,:) data(2,:,:) = var_ann_flip(55,:,:)*
>
> I don't really understand what you are trying to do conceptually, but a
> few comments:
>
> - In assigning one array to another, the size and shapes must be the same.
> It looks like you are trying to take 3 slices of var_ann_flip at level 55
> and assign it to the variable data. Those slices would each be a 2D
> subarray of dimension lat x lon. In that case, data needs to be
> dimensioned as I suggested:
>
> *Yes*
>
> data = new((/3,dimsizes(var_ann_flip&lat),dimsizes(var_ann_flip&lon)
> /),float)
>
> and then the assignments to data become:
>
> data(0,:,:) = var_ann_flip(55,:,:)
> data(1,:,:) = var_ann_flip(55,:,:)
> data(2,:,:) = var_ann_flip(55,:,:)
>
> - That takes care of the error message, but do you really mean for data
> 0..2 to contain the same slice (55) of var_ann_flip? Should they be
> different slices?
> *Yes*
> *0..2 are the variables O3, CO and NOX all at the surface level 55.*
>
> - All of this is contained inside a do-loop of three iterations. Is this
> correct? Were you trying to build up the data and plots iteratively?
>
> * Yes I tried to loop.*
> - Further down in the script, there is this:
>
> plot0 = gsn_csm_xy (wks,var_ann&lat,data(0,:,:),res)
> plot1 = gsn_csm_xy (wks,var_ann&lat,data(1,:,:),res)
> plot2 = gsn_csm_xy (wks,var_ann&lat,data(2,:,:),res)
>
> Note that the three plots are of the same data(0,:,:) -- should that be
> data(0,:,:) data(1,:,:) data(2,:,:)?
>
> *Thank you. They should be as you pointed out; data(0,:,:) for O3,
> data(1,:,:) for CO and data(2,;,;) for NOX.*
>
> *Please help. Thank you so much*
>
> *Najib*
>
>
>
> *------------------------------------*
> *Najib Yusuf Galadanci PhD*
> *Assistant Director (R & D)*
>
> Lower Atmospheric Dynamics
>
> (Aerosol radiative forcing, air quality observations and modeling)
>
> Centre for Atmospheric Research
>
> National Space Research and Development Agency. Kogi State
>
> University Campus, Anyigba. Kogi State. Nigeria
>
> +234 80 3871 4158
> ------------------------------------
> *Know that Victory comes with Patience, *
> *Relief with Affliction, and Ease with Hardship.*
> *Prophet Muhammad Rasulullah (PBUH)*
>
>
>
>
>
> On Thursday, June 9, 2022, 03:34:02 PM GMT+1, Rick Brownrigg <
> brownrig at ucar.edu> wrote:
>
>
> I don't really understand what you are trying to do conceptually, but a
> few comments:
>
> - In assigning one array to another, the size and shapes must be the same.
> It looks like you are trying to take 3 slices of var_ann_flip at level 55
> and assign it to the variable data. Those slices would each be a 2D
> subarray of dimension lat x lon. In that case, data needs to be
> dimensioned as I suggested:
>
> data = new((/3,dimsizes(var_ann_flip&lat),dimsizes(var_ann_flip&lon)
> /),float)
>
> and then the assignments to data become:
>
> data(0,:,:) = var_ann_flip(55,:,:)
> data(1,:,:) = var_ann_flip(55,:,:)
> data(2,:,:) = var_ann_flip(55,:,:)
>
> - That takes care of the error message, but do you really mean for data
> 0..2 to contain the same slice (55) of var_ann_flip? Should they be
> different slices?
>
> - All of this is contained inside a do-loop of three iterations. Is this
> correct? Were you trying to build up the data and plots iteratively?
>
> - Further down in the script, there is this:
>
> plot0 = gsn_csm_xy (wks,var_ann&lat,data(0,:,:),res)
> plot1 = gsn_csm_xy (wks,var_ann&lat,data(0,:,:),res)
> plot2 = gsn_csm_xy (wks,var_ann&lat,data(0,:,:),res)
>
> Note that the three plots are of the same data(0,:,:) -- should that be
> data(0,:,:) data(1,:,:) data(2,:,:)?
>
> Rick
>
>
> On Thu, Jun 9, 2022 at 7:55 AM Najib Yusuf <najibgal at yahoo.com> wrote:
>
> Hi Rick,
>
> Yes, data = new((/3,dimsizes(var_ann_flip&lat),dimsizes(var_ann_flip&lon)
> /),float)
>
> data(0,:) = var_ann_flip(55,:,:)
> data(1,:) = var_ann_flip(55,:,:)
> data(2,:) = var_ann_flip(55,:,:)
> left hand side is 2 dimension and right side is 3 dimension but the error
> is
> :Number of subscripts on left-hand-side do not match number of dimensions
> of variable: (2), Subscripts used: (3)
>
> It is not clear to me how I can make left hand side subscripting to 3
> because the dimension is 2. Kindly clear my confusion.
>
> Thank you sir
>
>
> *------------------------------------*
> *Najib Yusuf Galadanci PhD*
> *Assistant Director (R & D)*
>
> Lower Atmospheric Dynamics
>
> (Aerosol radiative forcing, air quality observations and modeling)
>
> Centre for Atmospheric Research
>
> National Space Research and Development Agency. Kogi State
>
> University Campus, Anyigba. Kogi State. Nigeria
>
> +234 80 3871 4158
> ------------------------------------
> *Know that Victory comes with Patience, *
> *Relief with Affliction, and Ease with Hardship.*
> *Prophet Muhammad Rasulullah (PBUH)*
>
>
>
>
>
> On Thursday, June 9, 2022, 02:41:44 PM GMT+1, Rick Brownrigg <
> brownrig at ucar.edu> wrote:
>
>
> Hi,
>
> The problem is just what the error message says; in these lines:
>
> data(0,:) = var_ann_flip(55,:,:)
> data(1,:) = var_ann_flip(55,:,:)
> data(2,:) = var_ann_flip(55,:,:)
>
> data is [3] x [192]
> whereas var_ann_flip is [lev | 56] x [lat | 192] x [lon | 288]
>
> I would speculate that the line that creates data should be something like:
>
> data = new((/3,dimsizes(var_ann_flip&lat),dimsizes(var_ann_flip&lon)
> /),float)
>
> Hope that helps...
> Rick
>
>
> On Thu, Jun 9, 2022 at 7:23 AM Najib Yusuf via ncl-talk <
> ncl-talk at mailman.ucar.edu> wrote:
>
> Dear NCL experts and colleagues,
>
> I am trying to plot multiple time series annual averages(monthly files) of
> three variables from same files using xy2 example, but I am getting error
> of dimension subscripting, when I tried using only One File it plotted.
> Kindly assist. See attached the script, and below is the VarSummaries. The
> error message is fatal:VarVarWrite: Number of dimensions on left hand
> side does not match right hand side.
>
> data(0,:) = var_ann_flip(55,:,:)
> data(1,:) = var_ann_flip(55,:,:)
> data(2,:) = var_ann_flip(55,:,:)
>
>
> Thank you for your support always
>
>
> Variable: f_all
> Type: string
> Total Size: 96 bytes
> 12 values
> Number of Dimensions: 1
> Dimensions and sizes: [12]
> Coordinates:
> (0) /glade/work/najiby/f.e20.FCSD/f.e20.FCSD/atm/hist/
> f.e20.FCSD.cam.h0.2013-01.nc
> (1) /glade/work/najiby/f.e20.FCSD/f.e20.FCSD/atm/hist/
> f.e20.FCSD.cam.h0.2013-02.nc
> (2) /glade/work/najiby/f.e20.FCSD/f.e20.FCSD/atm/hist/
> f.e20.FCSD.cam.h0.2013-03.nc
> (3) /glade/work/najiby/f.e20.FCSD/f.e20.FCSD/atm/hist/
> f.e20.FCSD.cam.h0.2013-04.nc
> (4) /glade/work/najiby/f.e20.FCSD/f.e20.FCSD/atm/hist/
> f.e20.FCSD.cam.h0.2013-05.nc
> (5) /glade/work/najiby/f.e20.FCSD/f.e20.FCSD/atm/hist/
> f.e20.FCSD.cam.h0.2013-06.nc
> (6) /glade/work/najiby/f.e20.FCSD/f.e20.FCSD/atm/hist/
> f.e20.FCSD.cam.h0.2013-07.nc
> (7) /glade/work/najiby/f.e20.FCSD/f.e20.FCSD/atm/hist/
> f.e20.FCSD.cam.h0.2013-08.nc
> (8) /glade/work/najiby/f.e20.FCSD/f.e20.FCSD/atm/hist/
> f.e20.FCSD.cam.h0.2013-09.nc
> (9) /glade/work/najiby/f.e20.FCSD/f.e20.FCSD/atm/hist/
> f.e20.FCSD.cam.h0.2013-10.nc
> (10) /glade/work/najiby/f.e20.FCSD/f.e20.FCSD/atm/hist/
> f.e20.FCSD.cam.h0.2013-11.nc
> (11) /glade/work/najiby/f.e20.FCSD/f.e20.FCSD/atm/hist/
> f.e20.FCSD.cam.h0.2013-12.nc
> (0) 1.016496e-05
> (0) 3.577813e-09
>
> Variable: var_ann
> Type: float
> Total Size: 12386304 bytes
> 3096576 values
> Number of Dimensions: 3
> Dimensions and sizes: [lev | 56] x [lat | 192] x [lon | 288]
> Coordinates:
> lev: [1.867879997007549..992.5000106104562]
> lat: [ -90.. 90]
> lon: [ 0..358.75]
> Number Of Attributes: 5
> cell_methods : time: mean
> long_name : O3 concentration
> units : mol/mol
> mdims : 1
> average_op_ncl : dim_avg_n over dimension(s): time
>
> Variable: var_ann_flip
> Type: float
> Total Size: 12386304 bytes
> 3096576 values
> Number of Dimensions: 3
> Dimensions and sizes: [lev | 56] x [lat | 192] x [lon | 288]
> Coordinates:
> lev: [1.867879997007549..992.5000106104562]
> lat: [ -90.. 90]
> lon: [-180..178.75]
> Number Of Attributes: 6
> cell_methods : time: mean
> long_name : O3 concentration
> units : mol/mol
> mdims : 1
> average_op_ncl : dim_avg_n over dimension(s): time
> lonFlip : longitude coordinate variable has been reordered via
> lonFlip
>
> Variable: data
> Type: float
> Total Size: 2304 bytes
> 576 values
> Number of Dimensions: 2
> Dimensions and sizes: [3] x [192]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : 9.96921e+36
> fatal:VarVarWrite: Number of dimensions on left hand side does not match
> right hand side
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 50 in
> file Timeser_annavg_O3CONOX.ncl
>
>
>
> *------------------------------------*
> *Najib Yusuf Galadanci PhD*
> *Assistant Director (R & D)*
>
> Lower Atmospheric Dynamics
>
> (Aerosol radiative forcing, air quality observations and modeling)
>
> Centre for Atmospheric Research
>
> National Space Research and Development Agency. Kogi State
>
> University Campus, Anyigba. Kogi State. Nigeria
>
> +234 80 3871 4158
> ------------------------------------
> *Know that Victory comes with Patience, *
> *Relief with Affliction, and Ease with Hardship.*
> *Prophet Muhammad Rasulullah (PBUH)*
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20220610/a5792c27/attachment.htm>
More information about the ncl-talk
mailing list