Menu

multiplication or squaring of variables

Help
2001-05-03
2013-10-17
  • Emilio Mayorga

    Emilio Mayorga - 2001-05-03

    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

     
    • Nobody/Anonymous

      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.

       
      • Emilio Mayorga

        Emilio Mayorga - 2001-05-04

        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

         
    • Charlie Zender

      Charlie Zender - 2001-05-04

      It is dying because NCO does not handle packed data.

      Charlie

       
      • Emilio Mayorga

        Emilio Mayorga - 2001-05-04

        Thanks, Charlie. I thought the packing attributes would just be ignored. -Emilio

         

Log in to post a comment.

MongoDB Logo MongoDB