I have a dataset that is lat, lon, wind, time. The time axis is very large because each member of an ensemble has been concatenated along the time axis.
So rather having a file of
X=180, Y=90, T=51000
Am looking to change the dimensions to
X=180, Y=90, T=100, Z=51
where Z is the ensemble member.
I've been looking for worked examples but unable to find something similar.
Thanks, Richard
Last edit: Richard Dixon 2019-10-16
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Henry - thanks for the quick reply, will give this a try, have not used any nco scripting on ncap2 before.
Just to clarify - I presume the $X and $Y are for the names of the X and Y co-ordinates, respectively? (I've used X and Y above but they're actually Lon and Lat).
Richard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi there - afraid I'm none the wiser on the above as it's all pretty new to me - maybe I need to provide more detail to help the script as it's crashing with a
ew.nco line 1, column 20: unexpected character '
A bit more detail on the data as I was a bit vague above: the contents of my netcdf file given by print (g.variables.keys()) is:
odict_keys(['time', 'lon', 'lat', '10fg'])
In terms of the shapes of the variables:
10fg (wind data) is (10965, 181, 360) - so (Time, Latitude, Longitude)
Lat is (181)
Lon is (360)
Time is (10965) - but time is just a repeating loop of 24 to 5160 in repeated 51 times over.
I would there like the time array to be 215, and a new dimension being Ensemble (51) that just counts upwards from 1 to 51.
i.e. 10fg would be (215, 51, 181, 360)
Hope this is a bit clearer (but doesn't make it harder)...
Thanks, Richard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
HI Richard,
An error on the first line ?
Thi s is the revised script - the wind variable "10fg" has to be quoted in ncap2 so that it can be distinguished from a plain number. This assumes that the lattiude coordinate variable is 'Lat' and the longitude coordinate variable is 'Lon'
Hi there
I have a dataset that is lat, lon, wind, time. The time axis is very large because each member of an ensemble has been concatenated along the time axis.
So rather having a file of
X=180, Y=90, T=51000
Am looking to change the dimensions to
X=180, Y=90, T=100, Z=51
where Z is the ensemble member.
I've been looking for worked examples but unable to find something similar.
Thanks, Richard
Last edit: Richard Dixon 2019-10-16
Hi Richard,
Its abit fiddly with ncap2 but possible.
Try the following script
/*** new.nco ****/
defdim("Tnw", 100);
defdim("Z", 51);
Tnw[Tnw]=T(::51)
windnw[$T, $Z, $Y, $X]=0.0;
windnw=wind;
/*******/
Then run the above script with the following command.
Then use ncrename to rename the variables "Tnw" and "windnw". and the dimension "Tnw". back to their original names
...Henry
Hi Henry - thanks for the quick reply, will give this a try, have not used any nco scripting on ncap2 before.
Just to clarify - I presume the $X and $Y are for the names of the X and Y co-ordinates, respectively? (I've used X and Y above but they're actually Lon and Lat).
Richard
Hi Richard,
$X and $Y are the lon dimension and the lat dimension.
So I guess you'll have to replace:
$X with $Lon
$Y with $Lat
X with Lon
Y with Lat
...Henry
Thanks, I will give it a try later. And sorry for using the wrong forum - please move to the Help one, if you can...!
Hi there - afraid I'm none the wiser on the above as it's all pretty new to me - maybe I need to provide more detail to help the script as it's crashing with a
ew.nco line 1, column 20: unexpected character '
A bit more detail on the data as I was a bit vague above: the contents of my netcdf file given by print (g.variables.keys()) is:
odict_keys(['time', 'lon', 'lat', '10fg'])
In terms of the shapes of the variables:
10fg (wind data) is (10965, 181, 360) - so (Time, Latitude, Longitude)
Lat is (181)
Lon is (360)
Time is (10965) - but time is just a repeating loop of 24 to 5160 in repeated 51 times over.
I would there like the time array to be 215, and a new dimension being Ensemble (51) that just counts upwards from 1 to 51.
i.e. 10fg would be (215, 51, 181, 360)
Hope this is a bit clearer (but doesn't make it harder)...
Thanks, Richard
HI Richard,
An error on the first line ?
Thi s is the revised script - the wind variable "10fg" has to be quoted in ncap2 so that it can be distinguished from a plain number. This assumes that the lattiude coordinate variable is 'Lat' and the longitude coordinate variable is 'Lon'
....Henry
Hi Henry
Many thanks for this - nearly there - one last thing is that I seem to lose the lat and lon variables in the process - the output file is:
odict_keys(['time_nw', 'Ensemble', 'wind_nw'])
Presumably I just need lines in there that are:
lat_nw[$lat_nw]=lat(0:180) and the like (I thought I'd check first up!)
Many thanks again
Richard
Hi Richard,
run the command line agin but omit the '-C' switch so all the used coordinate variables are pulled accross
Alternativly ammend the script as follows.
...Henry
Last edit: henry Butowsky 2019-10-18
Hi Henry - just wanted to thank you for all the help on this - all working!