PCMDI / nominal_resolution

tools to compute nominal resolution
3 stars 1 forks source link

bug in test to convert to radians #3

Open taylor13 opened 5 years ago

taylor13 commented 5 years ago

In the following code

    if data.max() > 20. or force:
        data = data / 180. * numpy.pi
    else:
        warnings.warn("It appears your data is already in radians, not touching it")
return data

we need an absolute value function applied to data.max() before testing whether it is >20.

doutriaux1 commented 5 years ago

in case of southern hemisphere only?

doutriaux1 commented 5 years ago

southern hemisphere with longitudes less than 0 but greater than 20W

taylor13 commented 5 years ago

consider a grid covering latitudes -90 to +20. In this case the current code won't convert to radians. (Also longitudes confined, for example, to -180 to 0)

doutriaux1 commented 5 years ago

only if the longitudes are also between -20 and 20.

doutriaux1 commented 5 years ago

it's unlikely but valid i agree.

taylor13 commented 5 years ago

not sure I follow. longitudes and latitudes are independent. If longitudes are in the range -180 to 20, the maximum value is 20, so conversion won't take place even though it should. This is independent of latitude.

doutriaux1 commented 5 years ago

my bad you're right. Multi tasking