[ncl-talk] Break line and multplying a value

Guilherme Martins jgmsantos at gmail.com
Sun May 29 13:15:52 MDT 2016


Dear Guido,

Thanks a lot for all informations. Your information helped me a lot.

About the break line, I'm getting error. I can't understand the reason.

Please could you take a look in my files (attachment)?

Guilherme.

Em dom, 29 de mai de 2016 às 15:25, Guido Cioni <guidocioni at gmail.com>
escreveu:

> Hey Guilherme,
>
> (1) The character “\” should work. I’ve used it several time to split in
> multiple lines the definition of a long array, e.g.
>
> qr(0,:)=(/avg(ps_3j_w->qr),    avg(ps_3j_wm20->qr), avg(ps_3j_wm30->qr),
> *\*
>           avg(ps_3j_wm40->qr), avg(ps_3j_wm50->qr), avg(ps_3j_wm60->qr)  /)
>
> Are you trying to do something similar? If you get an error maybe it’s
> because of the keyboard that has a different ASCII code for that character?
> I don’t know, just guessing…
> Doing that
>
> res at tiMainString = "Anomalia de altura geopotencial  \
>                                  em 500hPa - Fevereiro/1979”
>
> should produce the same result in the title of the plot.
>
> (2) Normally, no. But it depends on how you define it. If you have a
> variable with metadata and you just do an assignment to the same variable
> name, you won’t lose metadata. As an example
>
> wm2_to_mmh=rho_w*lv*1/(3600*1000)
>
> lhflx(0,:)=(/avg(ts_3j_w->lhflx)  ,avg(ts_3j_wm20->lhflx)
>  ,avg(ts_3j_wm30->lhflx), \
>              avg(ts_3j_wm40->lhflx)  ,avg(ts_3j_wm50->lhflx)
>  ,avg(ts_3j_wm60->lhflx)/)
> lhflx at longname="Mean Latent Heat Flux"
> lhflx at units="mm/h”
>
> *lhflx=lhflx/(-wm2_to_mmh)        *
>
> printVarSummary(lhflx)
>
> will produce
>
> Variable: lhflx
> Type: double
> Total Size: 96 bytes
>             12 values
> Number of Dimensions: 2
> Dimensions and sizes: [2] x [6]
> Coordinates:
> Number Of Attributes: 3
>   units : mm/h
>   longname : Mean Latent Heat Flux
>   _FillValue : 9.969209968386869e+36
>
> If you move the line lhflx=lhflx/(-wm2_to_mmh)  before the assignment of
> metadata (longname, units) you will get the same printout. *However*, if
> you define the algebraic operation at the same time as the assignment you
> will lose metadata. That is,
>
> lhflx(0,:)=(/avg(ts_3j_w->lhflx)  ,avg(ts_3j_wm20->lhflx)
>  ,avg(ts_3j_wm30->lhflx), \
>              avg(ts_3j_wm40->lhflx)  ,avg(ts_3j_wm50->lhflx)
>  ,avg(ts_3j_wm60->lhflx)  /)
> lhflx at longname="Mean Latent Heat Flux"
> lhflx at units="mm/h”
>
> *lhflx2*=lhflx/(-wm2_to_mmh)
>
> printVarSummary(lhflx2)
>
> would produce
>
> Variable: lhflx2
> Type: double
> Total Size: 96 bytes
>             12 values
> Number of Dimensions: 2
> Dimensions and sizes: [2] x [6]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue : 9.969209968386869e+36
>
> As you can see, type is the same (so the attribute _FillValue is
> preserved) but there are no longname and units metadata anymore.
>
> Hope this helps.
> Cheers
>
>
> Guido Cioni
> http://guidocioni.altervista.org
>
>
>
>
> Il giorno 29 mag 2016, alle ore 19:50, Guilherme Martins <
> jgmsantos at gmail.com> ha scritto:
>
> Hi users,
>
> How do I break a line in the NCL? I do not want the effect caused by the
> "~C~" but want to break the line within the script. I have a limit to
> write in that line.
>
> For example, that line is very long in my script and I want to break the
> line:
>
> res at tiMainString = "Anomalia de altura geopotencial em 500hPa -
> Fevereiro/1979"
>
> I tryed to use the "\", but does not work.
>
> Another issue I would like to understand why when we multiply any variable
> by a constant, this variable loses its metadata? I searched but I did not
> found anything.
>
> Thank you.
> --
>
> ------------------------------------------------------------------------------------------
> Dr. Guilherme Martins
> Instituto Nacional de Pesquisas Espaciais (INPE)
> Centro de Previsão de Tempo e Estudos Climáticos (CPTEC)
> Grupo de Desenvolvimento em Assimilação de Dados (GDAD)
> Telefone (INPE/CP): +55 12 3186-8551 || Celular (TIM): +55 12 98152-8580
> E-mail: guilherme.martins at inpe.br || jgmsantos at gmail.com
> Skype: guilherme.martins.
> Homepage: https://sites.google.com/site/jgmsantos
> Currículo Lattes: http://lattes.cnpq.br/5997657584785803
>
> ------------------------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
> --
------------------------------------------------------------------------------------------
Dr. Guilherme Martins
Instituto Nacional de Pesquisas Espaciais (INPE)
Centro de Previsão de Tempo e Estudos Climáticos (CPTEC)
Grupo de Desenvolvimento em Assimilação de Dados (GDAD)
Telefone (INPE/CP): +55 12 3186-8551 || Celular (TIM): +55 12 98152-8580
E-mail: guilherme.martins at inpe.br || jgmsantos at gmail.com
Skype: guilherme.martins.
Homepage: https://sites.google.com/site/jgmsantos
Currículo Lattes: http://lattes.cnpq.br/5997657584785803
------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160529/7677e86b/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: error message.pdf
Type: application/pdf
Size: 10301 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160529/7677e86b/attachment.pdf 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ex.ncl
Type: text/x-ncl
Size: 777 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160529/7677e86b/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hgt.jan.mar.1979.nc
Type: application/x-netcdf
Size: 67044 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160529/7677e86b/attachment.nc 


More information about the ncl-talk mailing list