Re: Reorganizing two arrays into one

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Mon Apr 15 2013 - 19:01:30 MDT

Hi Skylar,
I think you can just use index subscripting to do what you want. Try this:
MSL_SEASON_new= new((/46,241,480/),"float")
(You don't need to have a 4D array with the first dimension as size one.)

(assign dimension names and coordinate variables as you were)

then:
MSL_SEASON_new(0::2,:,:) = (/ MSL_SEASON(0,:,:,:) /) ; assign season 0
to the 0th, 2nd, 4th, etc time slots.
MSL_SEASON_new(1::2,:,:) = (/ MSL_SEASON(1,:,:,:) /) ; assign season 1
to the 1st, 3rd, 5th, etc time slots.

This is of course untested, so check the new array to make sure that the
above coding is doing what you want/expect it to.

If the above doesn't help please let ncl-talk know.
Adam

On 4/15/13 6:50 PM, Skylar Haines wrote:
> All,
>
> I have converted ERA Interim monthly data into seasonal data, DJF and
> JJA, and get my variable:
>
> Variable: MSL_season
> Type: float
> Total Size: 21285120 bytes
> 5321280 values
> Number of Dimensions: 4
> Dimensions and sizes:[season | 2] x [initial_time0_hours | 23] x
> [g0_lat_1 | 241] x [g0_lon_2 | 480]
> Coordinates:
> season: [DJF..JJA]
> initial_time0_hours: [1569072..1761936]
> g0_lat_1: [90..-90]
> g0_lon_2: [ 0..359.25]
> Number Of Attributes: 10
> center :European Center for Medium-Range Weather Forecasts (RSMC)
> long_name :Seasonal Means: Mean sea level pressure
> units :Pa
> _FillValue :1e+20
> level_indicator :1
> gds_grid_type :0
> parameter_table_version :128
> parameter_number :151
> forecast_time :0
> forecast_time_units :hours
> (0)nMSL_season=2
> (1)nMSL_season=23
> (2)nMSL_season=241
> (3)nMSL_season=480
>
>
> I would like to be able to have this data in a single array such that
> the seasons, DJF and JJA, are in relative order (i.e. DJF 1979, JJA
> 1979, DJF 1979-1980, JJA 1980, etc.):
>
> MSL_SEASON= new((/1,46,241,480/),"float")
> MSL_SEASON!0="season"
> MSL_SEASON!1="time"
> MSL_SEASON!2="lat"
> MSL_SEASON!3="lon"
>
>
> MSL_SEASON&season = season
> MSL_SEASON&time = time
> MSL_SEASON&lat = lat
> MSL_SEASON&lon = lon
>
>
> Seems to me like a simple task, but I have been struggling with it for
> a while now. I'm not sure whether a loop may be involved. I am not
> sure of the correct syntax regarding coordinate subscripting, either.
>
> Any help would greatly be appreciated.
>
> -Skylar
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Apr 15 19:01:38 2013

This archive was generated by hypermail 2.1.8 : Mon Apr 15 2013 - 20:12:25 MDT