[ncl-talk] Converting Weekly to Monthly data

Ipshita Majhi ipmajhi at alaska.edu
Tue Sep 9 22:55:46 MDT 2014


Dear NCL

How can I convert a weekly data to monthly and the time of the data is in
georgian form:-
Here are the global attributes for it

netcdf nhsce_v01r01_19661004_20140602 {
dimensions:
    cols = 88 ;
    rows = 88 ;
    time = UNLIMITED ; // (2487 currently)
variables:
    char coord_system ;
        coord_system:grid_mapping_name = "latitude_longitude" ;
        coord_system:longitude_of_central_meridian = 0. ;
        coord_system:semimajor_axis = 6378137 ;
        coord_system:semiminor_axis = 6356752.3 ;
    int time(time) ;
        time:standard_name = "time" ;
        time:long_name = "time" ;
        time:units = "days since 1966-10-03" ;
        time:axis = "T" ;
        time:valid_range = 7, 17409 ;
        time:calendar = "gregorian" ;
    float snow_cover_threshold ;
        snow_cover_threshold:standard_name = "surface_snow_area_fraction" ;
        snow_cover_threshold:long_name = "threshold for the
snow_cover_extent measurement" ;
        snow_cover_threshold:units = "1" ;

***********************************************************************

Here is my code and one of the fatal error is that i is undefined

; This program is to calculate the area average for snow for all the data
period
;*******************************************
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"
;*******************************************

;The intention is to average the sce for each year and for each month

a=addfile("~/Documents/Snow_cover_IMS/nhsce_v01r01_19661004_20140602.nc
","r")

sce=a->snow_cover_extent(0,:,:)

t=a->time
asciiwrite("time.txt",t); saving time as a text file

;Reading in the same text file

 time=asciiread("~/Documents/Snow_cover_IMS/NCL_codes/time.txt",-1,"float")

jan=new((/47,2/); I want the data to go from 1966 to 2012 with one column
with year information and other with data from sce
feb=new((/47,2/);
mar=new((/47,2/);
apr=new((/47,2/);
may=new((/47,2/);
june=new((/47,2/);
july=new((/47,2/);
aug=new((/47,2/);
sept=new((/47,2/);
oct=new((/47,2/);
nov=new((/47,2/);
dec=new((/47,2/);

 x = ispan (1,10,1)
years=ispan(1966,2012,1)
month=ispan(1,12,1)

for i=0,dimsizes(time)-1,7; since I saved time as a text file and the date
appears in a horizontal manner I am attaching the txt file
                        ;better clarity
t(nyr)==year(i)
if time(nyr+1)==1
jan(i)=(year(i),sce(i,:,:))
else if time(nyr+1)==2
feb(i)=(year(i),sce(i,:,:))
else if time(nyr+1)==3
mar(i)=(year(i),sce(i,:,:))
else if time(nyr+1)==4
apr(i)=(year(i),sce(i,:,:))
else if time(nyr+1)==5
may(i)=(year(i),sce(i,:,:))
else if time(nyr+1)==6
june(i)=(year(i),sce(i,;,:))
else if time(nyr+1)==7
july(i)=(year(i),sce(i,:,:))
else if time(nyr+1)==8
aug(i)=(year(i),sce(i,:,:))
else if time(nyr+1)==9
sept(i)=(year(i),sce(i,:,:))
else if time(nyr+1)==10
oct(i)=(year(i),sce(i,:,:))
else if time(nyr+1)==10
nov(i)=(year(i),sce(i,:,:))
else
dec(i)=(year(i),sce(i,:,:))
i=i+1
end

what is missing in the code!

I would be grateful for any guidance

Best Regards
Ipshita
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140909/ecc6dba3/attachment.html 
-------------- next part --------------
7
14
21
28
35
42
49
56
63
70
77
84
91
98
105
112
119
126
133
140
147
154
161
168
175
182
189
196
203
210
217
224
231
238
245
252
259
266
273
280
287
294
301
308
315
322
329
336
343
350
357
364
371
378
385
392
399
406
413
420
427
434
441
448
455
462
469
476
483
490
497
504
511
518
525
532
539
546
553
560
567
574
581
588
595
602
609
616
623
630
637
644
651
658
665
672
679
686
693
700
707
714
721
728
735
742
749
756
763
770
777
784
791
798
805
812
819
826
833
840
847
854
861
868
875
882
889
896
903
910
917
924
931
938
945
952
959
966
973
980
987
994
1001
1008
1015
1022
1029
1036
1043
1050
1057
1064
1071
1078
1085
1092
1099
1106
1113
1120
1127
1134
1141
1148
1155
1162
1169
1176
1183
1190
1197
1204
1211
1218
1225
1232
1239
1246
1253
1260
1267
1274
1281
1288
1295
1302
1309
1316
1323
1330
1337
1344
1351
1358
1365
1372
1379
1386
1393
1400
1407
1414
1421
1428
1435
1442
1449
1456
1463
1470
1477
1484
1491
1498
1505
1512
1519
1526
1533
1540
1547
1554
1561
1568
1575
1582
1589
1596
1603
1610
1617
1624
1631
1638
1645
1652
1659
1666
1673
1680
1687
1694
1701
1708
1715
1722
1729
1736
1743
1750
1757
1764
1771
1778
1785
1792
1799
1806
1813
1820
1827
1834
1841
1848
1855
1862
1869
1876
1883
1890
1897
1904
1911
1918
1925
1932
1939
1946
1953
1960
1967
1974
1981
1988
1995
2002
2009
2016
2023
2030
2037
2044
2051
2058
2065
2072
2079
2086
2093
2100
2107
2114
2121
2128
2135
2142
2149
2156
2163
2170
2177
2184
2191
2198
2205
2212
2219
2226
2233
2240
2247
2254
2261
2268
2275
2282
2289
2296
2303
2310
2317
2324
2331
2338
2345
2352
2359
2366
2373
2380
2387
2394
2401
2408
2415
2422
2429
2436
2443
2450
2457
2464
2471
2478
2485
2492
2499
2506
2513
2520
2527
2534
2541
2548
2555
2562
2569
2576
2583
2590
2597
2604
2611
2618
2625
2632
2639
2646
2653
2660
2667
2674
2681
2688
2695
2702
2709
2716
2723
2730
2737
2744
2751
2758
2765
2772
2779
2786
2793
2800
2807
2814
2821
2828
2835
2842
2849
2856
2863
2870
2877
2884
2891
2898
2905
2912
2919
2926
2933
2940
2947
2954
2961
2968
2975
2982
2989
2996
3003
3010
3017
3024
3031
3038
3045
3052
3059
3066
3073
3080
3087
3094
3101
3108
3115
3122
3129
3136
3143
3150
3157
3164
3171
3178
3185
3192
3199
3206
3213
3220
3227
3234
3241
3248
3255
3262
3269
3276
3283
3290
3297
3304
3311
3318
3325
3332
3339
3346
3353
3360
3367
3374
3381
3388
3395
3402
3409
3416
3423
3430
3437
3444
3451
3458
3465
3472
3479
3486
3493
3500
3507
3514
3521
3528
3535
3542
3549
3556
3563
3570
3577
3584
3591
3598
3605
3612
3619
3626
3633
3640
3647
3654
3661
3668
3675
3682
3689
3696
3703
3710
3717
3724
3731
3738
3745
3752
3759
3766
3773
3780
3787
3794
3801
3808
3815
3822
3829
3836
3843
3850
3857
3864
3871
3878
3885
3892
3899
3906
3913
3920
3927
3934
3941
3948
3955
3962
3969
3976
3983
3990
3997
4004
4011
4018
4025
4032
4039
4046
4053
4060
4067
4074
4081
4088
4095
4102
4109
4116
4123
4130
4137
4144
4151
4158
4165
4172
4179
4186
4193
4200
4207
4214
4221
4228
4235
4242
4249
4256
4263
4270
4277
4284
4291
4298
4305
4312
4319
4326
4333
4340
4347
4354
4361
4368
4375
4382
4389
4396
4403
4410
4417
4424
4431
4438
4445
4452
4459
4466
4473
4480
4487
4494
4501
4508
4515
4522
4529
4536
4543
4550
4557
4564
4571
4578
4585
4592
4599
4606
4613
4620
4627
4634
4641
4648
4655
4662
4669
4676
4683
4690
4697
4704
4711
4718
4725
4732
4739
4746
4753
4760
4767
4774
4781
4788
4795
4802
4809
4816
4823
4830
4837
4844
4851
4858
4865
4872
4879
4886
4893
4900
4907
4914
4921
4928
4935
4942
4949
4956
4963
4970
4977
4984
4991
4998
5005
5012
5019
5026
5033
5040
5047
5054
5061
5068
5075
5082
5089
5096
5103
5110
5117
5124
5131
5138
5145
5152
5159
5166
5173
5180
5187
5194
5201
5208
5215
5222
5229
5236
5243
5250
5257
5264
5271
5278
5285
5292
5299
5306
5313
5320
5327
5334
5341
5348
5355
5362
5369
5376
5383
5390
5397
5404
5411
5418
5425
5432
5439
5446
5453
5460
5467
5474
5481
5488
5495
5502
5509
5516
5523
5530
5537
5544
5551
5558
5565
5572
5579
5586
5593
5600
5607
5614
5621
5628
5635
5642
5649
5656
5663
5670
5677
5684
5691
5698
5705
5712
5719
5726
5733
5740
5747
5754
5761
5768
5775
5782
5789
5796
5803
5810
5817
5824
5831
5838
5845
5852
5859
5866
5873
5880
5887
5894
5901
5908
5915
5922
5929
5936
5943
5950
5957
5964
5971
5978
5985
5992
5999
6006
6013
6020
6027
6034
6041
6048
6055
6062
6069
6076
6083
6090
6097
6104
6111
6118
6125
6132
6139
6146
6153
6160
6167
6174
6181
6188
6195
6202
6209
6216
6223
6230
6237
6244
6251
6258
6265
6272
6279
6286
6293
6300
6307
6314
6321
6328
6335
6342
6349
6356
6363
6370
6377
6384
6391
6398
6405
6412
6419
6426
6433
6440
6447
6454
6461
6468
6475
6482
6489
6496
6503
6510
6517
6524
6531
6538
6545
6552
6559
6566
6573
6580
6587
6594
6601
6608
6615
6622
6629
6636
6643
6650
6657
6664
6671
6678
6685
6692
6699
6706
6713
6720
6727
6734
6741
6748
6755
6762
6769
6776
6783
6790
6797
6804
6811
6818
6825
6832
6839
6846
6853
6860
6867
6874
6881
6888
6895
6902
6909
6916
6923
6930
6937
6944
6951
6958
6965
6972
6979
6986
6993
7000
7007
7014
7021
7028
7035
7042
7049
7056
7063
7070
7077
7084
7091
7098
7105
7112
7119
7126
7133
7140
7147
7154
7161
7168
7175
7182
7189
7196
7203
7210
7217
7224
7231
7238
7245
7252
7259
7266
7273
7280
7287
7294
7301
7308
7315
7322
7329
7336
7343
7350
7357
7364
7371
7378
7385
7392
7399
7406
7413
7420
7427
7434
7441
7448
7455
7462
7469
7476
7483
7490
7497
7504
7511
7518
7525
7532
7539
7546
7553
7560
7567
7574
7581
7588
7595
7602
7609
7616
7623
7630
7637
7644
7651
7658
7665
7672
7679
7686
7693
7700
7707
7714
7721
7728
7735
7742
7749
7756
7763
7770
7777
7784
7791
7798
7805
7812
7819
7826
7833
7840
7847
7854
7861
7868
7875
7882
7889
7896
7903
7910
7917
7924
7931
7938
7945
7952
7959
7966
7973
7980
7987
7994
8001
8008
8015
8022
8029
8036
8043
8050
8057
8064
8071
8078
8085
8092
8099
8106
8113
8120
8127
8134
8141
8148
8155
8162
8169
8176
8183
8190
8197
8204
8211
8218
8225
8232
8239
8246
8253
8260
8267
8274
8281
8288
8295
8302
8309
8316
8323
8330
8337
8344
8351
8358
8365
8372
8379
8386
8393
8400
8407
8414
8421
8428
8435
8442
8449
8456
8463
8470
8477
8484
8491
8498
8505
8512
8519
8526
8533
8540
8547
8554
8561
8568
8575
8582
8589
8596
8603
8610
8617
8624
8631
8638
8645
8652
8659
8666
8673
8680
8687
8694
8701
8708
8715
8722
8729
8736
8743
8750
8757
8764
8771
8778
8785
8792
8799
8806
8813
8820
8827
8834
8841
8848
8855
8862
8869
8876
8883
8890
8897
8904
8911
8918
8925
8932
8939
8946
8953
8960
8967
8974
8981
8988
8995
9002
9009
9016
9023
9030
9037
9044
9051
9058
9065
9072
9079
9086
9093
9100
9107
9114
9121
9128
9135
9142
9149
9156
9163
9170
9177
9184
9191
9198
9205
9212
9219
9226
9233
9240
9247
9254
9261
9268
9275
9282
9289
9296
9303
9310
9317
9324
9331
9338
9345
9352
9359
9366
9373
9380
9387
9394
9401
9408
9415
9422
9429
9436
9443
9450
9457
9464
9471
9478
9485
9492
9499
9506
9513
9520
9527
9534
9541
9548
9555
9562
9569
9576
9583
9590
9597
9604
9611
9618
9625
9632
9639
9646
9653
9660
9667
9674
9681
9688
9695
9702
9709
9716
9723
9730
9737
9744
9751
9758
9765
9772
9779
9786
9793
9800
9807
9814
9821
9828
9835
9842
9849
9856
9863
9870
9877
9884
9891
9898
9905
9912
9919
9926
9933
9940
9947
9954
9961
9968
9975
9982
9989
9996
10003
10010
10017
10024
10031
10038
10045
10052
10059
10066
10073
10080
10087
10094
10101
10108
10115
10122
10129
10136
10143
10150
10157
10164
10171
10178
10185
10192
10199
10206
10213
10220
10227
10234
10241
10248
10255
10262
10269
10276
10283
10290
10297
10304
10311
10318
10325
10332
10339
10346
10353
10360
10367
10374
10381
10388
10395
10402
10409
10416
10423
10430
10437
10444
10451
10458
10465
10472
10479
10486
10493
10500
10507
10514
10521
10528
10535
10542
10549
10556
10563
10570
10577
10584
10591
10598
10605
10612
10619
10626
10633
10640
10647
10654
10661
10668
10675
10682
10689
10696
10703
10710
10717
10724
10731
10738
10745
10752
10759
10766
10773
10780
10787
10794
10801
10808
10815
10822
10829
10836
10843
10850
10857
10864
10871
10878
10885
10892
10899
10906
10913
10920
10927
10934
10941
10948
10955
10962
10969
10976
10983
10990
10997
11004
11011
11018
11025
11032
11039
11046
11053
11060
11067
11074
11081
11088
11095
11102
11109
11116
11123
11130
11137
11144
11151
11158
11165
11172
11179
11186
11193
11200
11207
11214
11221
11228
11235
11242
11249
11256
11263
11270
11277
11284
11291
11298
11305
11312
11319
11326
11333
11340
11347
11354
11361
11368
11375
11382
11389
11396
11403
11410
11417
11424
11431
11438
11445
11452
11459
11466
11473
11480
11487
11494
11501
11508
11515
11522
11529
11536
11543
11550
11557
11564
11571
11578
11585
11592
11599
11606
11613
11620
11627
11634
11641
11648
11655
11662
11669
11676
11683
11690
11697
11704
11711
11718
11725
11732
11739
11746
11753
11760
11767
11774
11781
11788
11795
11802
11809
11816
11823
11830
11837
11844
11851
11858
11865
11872
11879
11886
11893
11900
11907
11914
11921
11928
11935
11942
11949
11956
11963
11970
11977
11984
11991
11998
12005
12012
12019
12026
12033
12040
12047
12054
12061
12068
12075
12082
12089
12096
12103
12110
12117
12124
12131
12138
12145
12152
12159
12166
12173
12180
12187
12194
12201
12208
12215
12222
12229
12236
12243
12250
12257
12264
12271
12278
12285
12292
12299
12306
12313
12320
12327
12334
12341
12348
12355
12362
12369
12376
12383
12390
12397
12404
12411
12418
12425
12432
12439
12446
12453
12460
12467
12474
12481
12488
12495
12502
12509
12516
12523
12530
12537
12544
12551
12558
12565
12572
12579
12586
12593
12600
12607
12614
12621
12628
12635
12642
12649
12656
12663
12670
12677
12684
12691
12698
12705
12712
12719
12726
12733
12740
12747
12754
12761
12768
12775
12782
12789
12796
12803
12810
12817
12824
12831
12838
12845
12852
12859
12866
12873
12880
12887
12894
12901
12908
12915
12922
12929
12936
12943
12950
12957
12964
12971
12978
12985
12992
12999
13006
13013
13020
13027
13034
13041
13048
13055
13062
13069
13076
13083
13090
13097
13104
13111
13118
13125
13132
13139
13146
13153
13160
13167
13174
13181
13188
13195
13202
13209
13216
13223
13230
13237
13244
13251
13258
13265
13272
13279
13286
13293
13300
13307
13314
13321
13328
13335
13342
13349
13356
13363
13370
13377
13384
13391
13398
13405
13412
13419
13426
13433
13440
13447
13454
13461
13468
13475
13482
13489
13496
13503
13510
13517
13524
13531
13538
13545
13552
13559
13566
13573
13580
13587
13594
13601
13608
13615
13622
13629
13636
13643
13650
13657
13664
13671
13678
13685
13692
13699
13706
13713
13720
13727
13734
13741
13748
13755
13762
13769
13776
13783
13790
13797
13804
13811
13818
13825
13832
13839
13846
13853
13860
13867
13874
13881
13888
13895
13902
13909
13916
13923
13930
13937
13944
13951
13958
13965
13972
13979
13986
13993
14000
14007
14014
14021
14028
14035
14042
14049
14056
14063
14070
14077
14084
14091
14098
14105
14112
14119
14126
14133
14140
14147
14154
14161
14168
14175
14182
14189
14196
14203
14210
14217
14224
14231
14238
14245
14252
14259
14266
14273
14280
14287
14294
14301
14308
14315
14322
14329
14336
14343
14350
14357
14364
14371
14378
14385
14392
14399
14406
14413
14420
14427
14434
14441
14448
14455
14462
14469
14476
14483
14490
14497
14504
14511
14518
14525
14532
14539
14546
14553
14560
14567
14574
14581
14588
14595
14602
14609
14616
14623
14630
14637
14644
14651
14658
14665
14672
14679
14686
14693
14700
14707
14714
14721
14728
14735
14742
14749
14756
14763
14770
14777
14784
14791
14798
14805
14812
14819
14826
14833
14840
14847
14854
14861
14868
14875
14882
14889
14896
14903
14910
14917
14924
14931
14938
14945
14952
14959
14966
14973
14980
14987
14994
15001
15008
15015
15022
15029
15036
15043
15050
15057
15064
15071
15078
15085
15092
15099
15106
15113
15120
15127
15134
15141
15148
15155
15162
15169
15176
15183
15190
15197
15204
15211
15218
15225
15232
15239
15246
15253
15260
15267
15274
15281
15288
15295
15302
15309
15316
15323
15330
15337
15344
15351
15358
15365
15372
15379
15386
15393
15400
15407
15414
15421
15428
15435
15442
15449
15456
15463
15470
15477
15484
15491
15498
15505
15512
15519
15526
15533
15540
15547
15554
15561
15568
15575
15582
15589
15596
15603
15610
15617
15624
15631
15638
15645
15652
15659
15666
15673
15680
15687
15694
15701
15708
15715
15722
15729
15736
15743
15750
15757
15764
15771
15778
15785
15792
15799
15806
15813
15820
15827
15834
15841
15848
15855
15862
15869
15876
15883
15890
15897
15904
15911
15918
15925
15932
15939
15946
15953
15960
15967
15974
15981
15988
15995
16002
16009
16016
16023
16030
16037
16044
16051
16058
16065
16072
16079
16086
16093
16100
16107
16114
16121
16128
16135
16142
16149
16156
16163
16170
16177
16184
16191
16198
16205
16212
16219
16226
16233
16240
16247
16254
16261
16268
16275
16282
16289
16296
16303
16310
16317
16324
16331
16338
16345
16352
16359
16366
16373
16380
16387
16394
16401
16408
16415
16422
16429
16436
16443
16450
16457
16464
16471
16478
16485
16492
16499
16506
16513
16520
16527
16534
16541
16548
16555
16562
16569
16576
16583
16590
16597
16604
16611
16618
16625
16632
16639
16646
16653
16660
16667
16674
16681
16688
16695
16702
16709
16716
16723
16730
16737
16744
16751
16758
16765
16772
16779
16786
16793
16800
16807
16814
16821
16828
16835
16842
16849
16856
16863
16870
16877
16884
16891
16898
16905
16912
16919
16926
16933
16940
16947
16954
16961
16968
16975
16982
16989
16996
17003
17010
17017
17024
17031
17038
17045
17052
17059
17066
17073
17080
17087
17094
17101
17108
17115
17122
17129
17136
17143
17150
17157
17164
17171
17178
17185
17192
17199
17206
17213
17220
17227
17234
17241
17248
17255
17262
17269
17276
17283
17290
17297
17304
17311
17318
17325
17332
17339
17346
17353
17360
17367
17374
17381
17388
17395
17402
17409


More information about the ncl-talk mailing list