nsidc / nsidc0756-scripts

Scripts related to NSIDC-0756
https://nsidc.org/data/nsidc-0756
Other
3 stars 1 forks source link

xy2ll error in solving for rho #3

Open SamKodama opened 2 years ago

SamKodama commented 2 years ago

I attempted to use the xy2ll for both MATLAB and python. I used the x and y data from the BedMachine .nc file. In both instances of running the script I ran into the errors For Python: ufunc 'square' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

For MATLAB: Check for incorrect argument data type or missing argument in call to function 'sqrt'. rho=sqrt(x.^2+y.^2);

In Python I was able to fix the issue by importing the x and y values as a dtype='int64' numpy array. Some stackoverflow searchers made it seem like the error was an integer overflow issue. However the output longitude values only varied from -45 to 135 and not -180 to 180.

Any help would be much appreciated.

rdPatmore commented 2 years ago

I presume you got past your issue, but adding this in case it is helpful to others.

I had the same issue here with the data type. I added a simple check to deal with the int64 issue.

I believe you're latter issue was to do with the fact that you need to use a meshgrid of x,y:

xs, ys = np.meshgrid(x, y)

and input xs, ys into the xy2ll function. Using just x and y does not capture all the combinations of x and y.