I want to create a new variable, wind speed, from the u and v components: speed = (u^2 + v^2)^0.5. Can NCO do this? I've looked through the Manual and can't find anything relevant; ncflint doesn't multiply two variables. I also looked through the examples in the test battery file, but found nothing.
Can NCO do it?
Thanks.
Emilio Mayorga
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I believe NCO can do this in 5--10 commands.
Use ncwa -v u -w u and turn off normalization.
That should get you u^2. Do the same for v^2.
Add the two using ncdiff and subtracting -v^2.
How do you get -v^2? subtract v^2 from itself
twice. you'll need to use ncrename in order
to get u^2 + v^2. Then just use ncwa -y sqrt.
Disclaimer: this may work better in my head
than it does in practice. Good luck.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the tip (Charlie? I don't know who wrote that reply). I can see where it's going. I tested ncwa -N -v u -w u, but got Segmentation Fault every time (I tried changing the averaging dimensions specified with -a). The variable is short int-type, and has a scale_factor and add_offset. Looking at the data-type conversion section in the Manual, it seems possible that trying to square a short int while saving the result as the same data type may create an out-of-bounds problem.
I'd be interested in hearing your opinion on this, but I've found a way of accomplishing my task using Ferret instead of NCO. Thanks. -Emilio
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I want to create a new variable, wind speed, from the u and v components: speed = (u^2 + v^2)^0.5. Can NCO do this? I've looked through the Manual and can't find anything relevant; ncflint doesn't multiply two variables. I also looked through the examples in the test battery file, but found nothing.
Can NCO do it?
Thanks.
Emilio Mayorga
I believe NCO can do this in 5--10 commands.
Use ncwa -v u -w u and turn off normalization.
That should get you u^2. Do the same for v^2.
Add the two using ncdiff and subtracting -v^2.
How do you get -v^2? subtract v^2 from itself
twice. you'll need to use ncrename in order
to get u^2 + v^2. Then just use ncwa -y sqrt.
Disclaimer: this may work better in my head
than it does in practice. Good luck.
Thanks for the tip (Charlie? I don't know who wrote that reply). I can see where it's going. I tested ncwa -N -v u -w u, but got Segmentation Fault every time (I tried changing the averaging dimensions specified with -a). The variable is short int-type, and has a scale_factor and add_offset. Looking at the data-type conversion section in the Manual, it seems possible that trying to square a short int while saving the result as the same data type may create an out-of-bounds problem.
I'd be interested in hearing your opinion on this, but I've found a way of accomplishing my task using Ferret instead of NCO. Thanks. -Emilio
It is dying because NCO does not handle packed data.
Charlie
Thanks, Charlie. I thought the packing attributes would just be ignored. -Emilio