Re: Not able to open multiple netcdf

From: Nitin Patil <nitinpatil85_at_nyahnyahspammersnyahnyah>
Date: Tue Apr 01 2014 - 03:58:27 MDT

Thanks

--
Regards,
Nitin Patil
On Tue, Apr 1, 2014 at 3:07 PM, Karin Meier-Fleischer <
meier-fleischer@dkrz.de> wrote:
>  Hi Nitil,
>
> got it. You have to create a loop over the files to write to them:
>
> do i=0,nfiles-1
>    fout = in[i]
>    fout->LAY=(/LAY/)
>    fout->COL=(/COL/)
>    fout->ROW=(/ROW/)
>    fout->TSTEP=(/TSTEP/)
>    delete(fout)
> end do
>
>
> Bye,
> Karin
>
> Am 01.04.14 10:58, schrieb Nitin Patil:
>
>  Thanks for your time but i tried and I got
>
> for your first solution:
> fatal:No valid instance of variable LAY found in file list
>
>  for second solution:
> fatal:ListSelect: Index out of range
>
>  any idea!!
>
>  --
> Regards,
> Nitin Patil
>
>
> On Tue, Apr 1, 2014 at 2:20 PM, Karin Meier-Fleischer <
> meier-fleischer@dkrz.de> wrote:
>
>>  Hi Nitin,
>>
>> To read from all files you have to use
>>
>> in[:]->LAY=(/LAY/)
>> in[:]->COL=(/COL/)
>> in[:]->ROW=(/ROW/)
>> in[:]->TSTEP=(/TSTEP/)
>>
>> Or to read from a single file of the list of all files, e.g. the 3rd file
>>
>> in[2]->LAY=(/LAY/)
>> in[2]->COL=(/COL/)
>> in[2]->ROW=(/ROW/)
>> in[2]->TSTEP=(/TSTEP/)
>>
>> Bye,
>> Karin
>>
>> Am 01.04.14 10:29, schrieb Nitin Patil:
>>
>>   Thanks for your quick reply.
>>
>>  I am using w to write in to nc file.
>>  my script is:
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>>
>>
>> begin
>>
>> all_files = systemfunc ("ls *.nc")
>>
>> in = addfiles(all_files, "w")
>>  print(in)
>>
>> ;in = addfile("TROUT.05-01-00.nc","w")
>>
>> LAY = (/29.729, 102.144, 200.755, 326.211, 483.806, 683.912, 928.836,\
>>     1200.985, 1483.997, 1775.847, 2076.479, 2521.568, 3107.312,
>> 3693.588,\
>>     4279.533, 4867.32, 5456.567, 6045.179, 6633.718, 7222.439, 7811.873,\
>>     8402.041, 8992.414, 9582.481, 10171.88, 10760.3, 11347.47, 11932.92,\
>>     12517.15, 13102.11, 13689.32, 14279, 14871.05, 15465.91, 16064.9,\
>>     16672.23, 17294.92, 17940.52, 18615.93, 19327.65, 20081.03/)
>>
>> COL = (/37.82249, 38.07713, 38.33177, 38.58641, 38.84105, 39.09569,
>> 39.35033,\
>>     39.60497, 39.85962, 40.11425, 40.36889, 40.62354, 40.87818,
>> 41.13282,\
>>     41.38745, 41.6421, 41.89674, 42.15138, 42.40602, 42.66066, 42.9153,\
>>     43.16994, 43.42458, 43.67922, 43.93386, 44.1885, 44.44314,
>> 44.69778,\
>>     44.95242, 45.20707, 45.4617, 45.71635, 45.97099, 46.22563,
>> 46.48027,\
>>     46.73491, 46.98955, 47.24419, 47.49883, 47.75347, 48.00811,
>> 48.26275,\
>>     48.51739, 48.77203, 49.02667, 49.28131, 49.53595, 49.79059,
>> 50.04523,\
>>     50.29987, 50.55451, 50.80915, 51.0638, 51.31844, 51.57307,
>> 51.82771,\
>>     52.08236, 52.337, 52.59164, 52.84628, 53.10092, 53.35556, 53.6102,\
>>     53.86484, 54.11948, 54.37412, 54.62876, 54.8834, 55.13804,
>> 55.39268,\
>>     55.64732, 55.90196, 56.1566, 56.41125, 56.66589, 56.92052,
>> 57.17516,\
>>     57.42981, 57.68445, 57.93909, 58.19373, 58.44837, 58.70301,
>> 58.95765,\
>>     59.21229, 59.46693, 59.72157, 59.97621, 60.23085, 60.48549,
>> 60.74014,\
>>     60.99477, 61.24941, 61.50406, 61.75869, 62.01334, 62.26797,
>> 62.52262,\
>>     62.77726, 63.0319, 63.28654, 63.54118, 63.79582, 64.05046, 64.3051,\
>>     64.55974, 64.81438, 65.06902, 65.32366, 65.5783, 65.83294,
>> 66.08759,\
>>     66.34222, 66.59686, 66.8515, 67.10615, 67.36079, 67.61543,
>> 67.87006,\
>>     68.12471, 68.37935, 68.63399, 68.88863, 69.14327, 69.39791,
>> 69.65255,\
>>     69.90719, 70.16183, 70.41647, 70.67111, 70.92575, 71.18039,
>> 71.43504,\
>>     71.68967, 71.94431, 72.19895, 72.4536, 72.70824, 72.96288,
>> 73.21751,\
>>     73.47216, 73.7268, 73.98144, 74.23608, 74.49072, 74.74536, 75,
>> 75.25464,\
>>     75.50928, 75.76392, 76.01856, 76.2732, 76.52784, 76.78249,
>> 77.03712,\
>>     77.29176, 77.5464, 77.80105, 78.05569, 78.31033, 78.56496,
>> 78.81961,\
>>     79.07425, 79.32889, 79.58353, 79.83817, 80.09281, 80.34745,
>> 80.60209,\
>>     80.85673, 81.11137, 81.36601, 81.62065, 81.87529, 82.12994,
>> 82.38457,\
>>     82.63921, 82.89385, 83.1485, 83.40314, 83.65778, 83.91241,
>> 84.16706,\
>>     84.4217, 84.67634, 84.93098, 85.18562, 85.44026, 85.6949, 85.94954,\
>>     86.20418, 86.45882, 86.71346, 86.9681, 87.22274, 87.47739,
>> 87.73203,\
>>     87.98666, 88.2413, 88.49595, 88.75059, 89.00523, 89.25986,
>> 89.51451,\
>>     89.76915, 90.02379, 90.27843, 90.53307, 90.78771, 91.04235,
>> 91.29699,\
>>     91.55163, 91.80627, 92.06091, 92.31555, 92.57019, 92.82484,
>> 93.07948,\
>>     93.33411, 93.58875, 93.8434, 94.09804, 94.35268, 94.60732,
>> 94.86195,\
>>     95.1166, 95.37124, 95.62588, 95.88052, 96.13516, 96.3898, 96.64444,\
>>     96.89908, 97.15372, 97.40836, 97.663, 97.91764, 98.17229, 98.42693,\
>>     98.68156, 98.9362, 99.19085, 99.44549, 99.70013, 99.95477,
>> 100.2094,\
>>     100.4641, 100.7187, 100.9733, 101.228, 101.4826, 101.7373,
>> 101.9919,\
>>     102.2465, 102.5012, 102.7558, 103.0105, 103.2651, 103.5197,
>> 103.7744,\
>>     104.029, 104.2837, 104.5383, 104.7929, 105.0476, 105.3022,
>> 105.5569,\
>>     105.8115, 106.0661, 106.3208, 106.5754, 106.8301, 107.0847,
>> 107.3393,\
>>     107.594, 107.8486, 108.1033, 108.3579, 108.6125, 108.8672,
>> 109.1218,\
>>     109.3765, 109.6311, 109.8857, 110.1404, 110.395, 110.6497,
>> 110.9043,\
>>     111.159, 111.4136, 111.6682, 111.9229, 112.1775, 112.4321,
>> 112.6868,\
>>     112.9414, 113.1961, 113.4507, 113.7054, 113.96, 114.2146, 114.4693,\
>>     114.7239, 114.9786, 115.2332, 115.4878, 115.7425, 115.9971,
>> 116.2518,\
>>     116.5064, 116.761, 117.0157, 117.2703, 117.525, 117.7796, 118.0342,\
>>     118.2889, 118.5435, 118.7982, 119.0528, 119.3074, 119.5621,
>> 119.8167,\
>>     120.0714, 120.326, 120.5806, 120.8353, 121.0899, 121.3446,
>> 121.5992,\
>>     121.8539/)
>>
>> ROW = (/-6.398895, -6.145782, -5.892532, -5.639191, -5.385719,
>> -5.132149,\
>>     -4.878487, -4.624725, -4.370865, -4.116928, -3.8629, -3.608803,
>> -3.35463,\
>>     -3.100395, -2.846092, -2.591743, -2.337341, -2.082886, -1.8284,\
>>     -1.573868, -1.319305, -1.064728, -0.8101196, -0.5554962,
>> -0.3008652,\
>>     -0.04621887, 0.2084122, 0.4630508, 0.7176819, 0.9722977, 1.226891,\
>>     1.481453, 1.735992, 1.990509, 2.244965, 2.49939, 2.753769, 3.00808,\
>>     3.262337, 3.516533, 3.77066, 4.024712, 4.278687, 4.53257, 4.786369,\
>>     5.040077, 5.293678, 5.54718, 5.800575, 6.053848, 6.307014,
>> 6.560051,\
>>     6.812958, 7.065735, 7.318375, 7.570869, 7.823204, 8.075401,
>> 8.327438,\
>>     8.579315, 8.831017, 9.08255, 9.333908, 9.585098, 9.836082,
>> 10.08688,\
>>     10.33749, 10.5879, 10.8381, 11.08809, 11.33788, 11.58743, 11.83677,\
>>     12.08588, 12.33476, 12.58341, 12.8318, 13.07996, 13.32787,
>> 13.57553,\
>>     13.82293, 14.07005, 14.31693, 14.56352, 14.80984, 15.05589,
>> 15.30164,\
>>     15.5471, 15.79228, 16.03716, 16.28175, 16.52602, 16.76999,
>> 17.01364,\
>>     17.25698, 17.49999, 17.74269, 17.98505, 18.22708, 18.46877,
>> 18.71013,\
>>     18.95114, 19.1918, 19.43211, 19.67207, 19.91167, 20.15091,
>> 20.38978,\
>>     20.62828, 20.86641, 21.10416, 21.34153, 21.57851, 21.81512,
>> 22.05132,\
>>     22.28713, 22.52256, 22.75758, 22.99219, 23.22639, 23.46019,
>> 23.69358,\
>>     23.92654, 24.1591, 24.39122, 24.62292, 24.85419, 25.08504,
>> 25.31543,\
>>     25.5454, 25.77493, 26.00401, 26.23266, 26.46084, 26.68857,
>> 26.91586,\
>>     27.14268, 27.36905, 27.59496, 27.8204, 28.04537, 28.26988,
>> 28.49391,\
>>     28.71747, 28.94055, 29.16315, 29.38527, 29.6069, 29.82806,
>> 30.04872,\
>>     30.26889, 30.48857, 30.70776, 30.92645, 31.14463, 31.36232,
>> 31.57949,\
>>     31.79617, 32.01234, 32.22802, 32.44317, 32.6578, 32.87193,
>> 33.08555,\
>>     33.29864, 33.51121, 33.72326, 33.93478, 34.1458, 34.35628,
>> 34.56622,\
>>     34.77567, 34.98456, 35.19292, 35.40073, 35.60803, 35.8148,
>> 36.02101,\
>>     36.2267, 36.43185, 36.63645, 36.84052, 37.04402, 37.247, 37.44944,\
>>     37.65132, 37.85266, 38.05345, 38.25368, 38.45337, 38.65251,
>> 38.85109,\
>>     39.04912, 39.24661, 39.44353, 39.63989, 39.83571, 40.03096,
>> 40.22566,\
>>     40.4198, 40.61339, 40.80641, 40.99887, 41.19077, 41.38211,
>> 41.57291,\
>>     41.76311, 41.95277, 42.14188, 42.3304, 42.51837, 42.70576,
>> 42.89261,\
>>     43.07887, 43.26459, 43.44974, 43.63431, 43.81833, 44.00179,
>> 44.18466,\
>>     44.36699/)
>>
>> TSTEP = (/0, 6, 12, 18/)
>>
>> in->LAY=(/LAY/)
>> in->COL=(/COL/)
>> in->ROW=(/ROW/)
>> in->TSTEP=(/TSTEP/)
>>
>> end
>>
>>  error is coming on line in->LAY=(/LAY/)
>> fatal:(in) does not reference a file
>> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 108 in
>> file attribute.ncl
>>
>>  any idea...
>>
>>
>>  --
>> Regards,
>> Nitin Patil
>>
>>
>> On Tue, Apr 1, 2014 at 1:56 PM, Karin Meier-Fleischer <
>> meier-fleischer@dkrz.de> wrote:
>>
>>>  Hi Nitin,
>>>
>>> could you give us more information about what is not working (e.g.
>>> script and
>>> error message).
>>>
>>> How do you use the 'in' variable? If you use addfiles you have to define
>>> a variable
>>> contained in all files like this
>>>
>>>
>>> in  = addfiles(all_files,"w")
>>>  var = in[:]->u10
>>>
>>> If you want the variable to be read only from the 3rd file you have to do
>>>
>>> var = in[2]->u10
>>>
>>> See also  http://ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml
>>>
>>> Bye,
>>> Karin
>>>
>>> Am 01.04.14 08:37, schrieb Nitin Patil:
>>>
>>>    Dear ncl users,
>>>
>>>  I am trying to open multiple netcdf files as follows:
>>>
>>> all_files = systemfunc ("ls /home/nitin/Documents/3_STEM-HAM/try/*.nc")
>>> in = addfiles(all_files, "w")
>>>
>>>  but it is not opening, When i am trying to open single file like:
>>> in = addfile("TROUT.05-*-00.nc","w")  it is opening and script is
>>> working.
>>>
>>>  Any suggestion and help is appreciated, kindly let me know.
>>>
>>>
>>>   --
>>> Regards,
>>> Nitin Patil
>>>
>>>
>>>  _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>> --
>>> Dipl. Geophys. Karin Meier-Fleischer
>>> Application Support, Visualization
>>>
>>> Deutsches Klimarechenzentrum GmbH      E-Mail:   meier-fleischer@dkrz.de
>>> Bundesstrasse 45a                      Internet: http://www.dkrz.de/
>>> 20146 Hamburg                          Phone:    +49 (0)40 460094 126
>>> Germany                                Fax:      +49 (0)40 460094 270
>>>
>>> Geschäftsführer: Prof. Dr. Thomas Ludwig
>>> Sitz der Gesellschaft: Hamburg
>>> Amtsgericht Hamburg HRB 39784
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>> --
>> Dipl. Geophys. Karin Meier-Fleischer
>> Application Support, Visualization
>>
>> Deutsches Klimarechenzentrum GmbH      E-Mail:   meier-fleischer@dkrz.de
>> Bundesstrasse 45a                      Internet: http://www.dkrz.de/
>> 20146 Hamburg                          Phone:    +49 (0)40 460094 126
>> Germany                                Fax:      +49 (0)40 460094 270
>>
>> Geschäftsführer: Prof. Dr. Thomas Ludwig
>> Sitz der Gesellschaft: Hamburg
>> Amtsgericht Hamburg HRB 39784
>>
>>
>
> --
> Dipl. Geophys. Karin Meier-Fleischer
> Application Support, Visualization
>
> Deutsches Klimarechenzentrum GmbH      E-Mail:   meier-fleischer@dkrz.de
> Bundesstrasse 45a                      Internet: http://www.dkrz.de/
> 20146 Hamburg                          Phone:    +49 (0)40 460094 126
> Germany                                Fax:      +49 (0)40 460094 270
>
> Geschäftsführer: Prof. Dr. Thomas Ludwig
> Sitz der Gesellschaft: Hamburg
> Amtsgericht Hamburg HRB 39784
>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Apr 1 03:58:42 2014

This archive was generated by hypermail 2.1.8 : Thu Apr 03 2014 - 13:36:27 MDT