1

I was wondering how to change the dtype from float32 to float64 of coordinates.

I can run the following code in the terminal

ncap2 -s 'lat=double(lat); lon=double(lon)' infile.nc outfile.nc

However when I try the following ncap2 command in python I get the error too many input files.

nco.ncap2(input='infile.nc', output='outfile.nc', options=['-s','lat=double(lat); lon=double(lon);'])

also tried with ncatted2

nco.ncatted(input='infile.nc', output='out.nc', options=['-a','lat=double(lat); lon=double(lon);'])

This one just compiles without doing anything.

ClimateUnboxed
8,1866 gold badges49 silver badges100 bronze badges
asked Nov 1, 2023 at 13:32
2
  • Is the "doubel" just a typo here or was it also an error in your script? Commented Nov 1, 2023 at 13:39
  • Oh that was just a typo. Have edited the question. Commented Nov 1, 2023 at 13:57

1 Answer 1

2

I think that it is the spaces in the options string messing it up, the cdo and nco bindings don't like padding spaces when there is more than one option (i.e. it would be like trying your direct terminal command without the surrounding quote marks on the -s option).

This should work, it did for me:

nco.ncap2(input='infile.nc', output='outfile.nc', options=['-s','lat=double(lat);lon=double(lon)'])
answered Nov 1, 2023 at 14:36
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.