[ncl-talk] concatenating arrays in PynGL

Rick Brownrigg brownrig at ucar.edu
Fri Jun 7 10:34:51 MDT 2019


It seems like np.append() will work. You definitely have to use the axis=0
argument, otherwise the result is flattened.

Rick

On Fri, Jun 7, 2019 at 9:14 AM Mahesh Kovilakam <mkmvarma at gmail.com> wrote:

>
> I just want to append these two arrays so that the new variable will have
> values from 1979 through 2018. In NCL, I just use
> array_append_record(ext_525,merged_ext_525) which will produce an array
> that goes from 1979 through 2018. I am not sure in python, the "np.append"
> can be used.
>
> On Fri, Jun 7, 2019 at 11:05 AM Alessandra Giannini <
> alesall at iri.columbia.edu> wrote:
>
>>
>> hi, are you sure that you want to concatenate these two matrices?
>> According to the information you printed out, time intervals are
>> 1979-2016 for one, and 2002-2018 for the other…
>> warm regards, alessandra
>>
>>
>>
>>>> Alessandra Giannini
>> IRI for Climate and Society - The Earth Institute at Columbia University
>> P.O. Box 1000, Palisades NY 10964-8000
>> phone/fax: +1 845 680-4473/4864 - email: alesall at iri.columbia.edu
>> <alesall at iri.columbia.edu>
>>
>>
>>
>>
>> On Jun 7, 2019, at 10:54 AM, Mahesh Kovilakam <mkmvarma at gmail.com> wrote:
>>
>> Hi,
>> I am now transitioning to python and I recently installed PynGL and now
>> converting one NCL script to python. I would like to concatenate two arrays
>> and in NCL it was easy using "array_append_record". For python, I used "
>> np.concatenate(array1,array2,axis=0)" but it gives me this error:
>>
>>   File "MERGE_netcdf_test.py", line 86, in <module>
>>     merge_data = np.concatenate(ext_525_v11,ext_525_v2,axis=0)
>> TypeError: 'NioVariable' object cannot be interpreted as an integer
>>
>> I am not sure what that means. Here are the two variables I am trying to
>> concatenate:
>>
>> Variable: ext_525
>> Type: float
>> Total Size: 5253120 bytes
>>             1313280 values
>> Number of Dimensions: 4
>> Dimensions and sizes: [year | 38] x [month | 12] x [lat | 32] x [alt |
>> 90]
>> Coordinates:
>>             year: [1979..2016]
>>             month: [1..12]
>>             lat: [-77.5..77.5]
>>             alt: [0.5..45]
>> Number of Attributes: 2
>>          _FillValue : -999
>>          mwv : 0.525
>>
>> Variable: MERGED_EXT_525
>> Type: float
>> Total Size: 2350080 bytes
>>             587520 values
>> Number of Dimensions: 4
>> Dimensions and sizes: [year | 17] x [month | 12] x [lat | 32] x [alt |
>> 90]
>> Coordinates:
>>             year: [2002..2018]
>>             month: [1..12]
>>             lat: [-77.5..77.5]
>>             alt: [0.5..45]
>> Number of Attributes: 6
>>          mwv : 0.525
>>          description : zonally averaged cloud cleared extinction at 525
>> nm
>>          average_op_ncl : dim_avg_n over dimension(s): profiles
>>          long_name : merged extinction from OSIRIS, CALIPSO, and
>> SAGEIII-ISS at 525 nm
>>          units : 1/km
>>          _FillValue : -999
>>
>>
>> And my apologies of posting this question in NCL talk. I don't know if I
>> could post this question to any other forum so posting it here.
>>
>> Thanks,
>> Mahesh
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190607/f0b307d3/attachment.html>


More information about the ncl-talk mailing list