I am trying to write a csv file to netcdf using very similar code to what is provided here convert csv to netcdf because my data is very similar e.g. also ocean data
I am writing my variables and appending the same way as above script but am having a problem with my latitude and longitude variables. In the above example the command
lats_out = -25.0 + 5.0 * arange(v4, dtype='float32')
is used, however when I try this I receive this error
>>> lats_out = -90.0 + 90.0 * arange(v4, dtype='float32')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'list' and 'int'
which is logical because v4 is a list and the points within it are stored as float values, but it itself is not a float value.
>>> type(v4)
<type 'list'>
>>> type(v4[1])
<type 'float'>
I do not understand how this was not a problem for the person running the previous script, or how to solve it. I cannot skip this stage out because later when trying to write a variable latitude that uses the dimension lat the slice has a different shape to each other. Any help much appreciated as I am very new to python!