1

I am writing a code to calculate the heat index using Metpy 1.0 library. However, when running the code I am getting this error : 'numpy.ndarray' object has no attribute 'to'

How to solve this error. I thoroughly follow the instructions on a tutorial (https://www.youtube.com/watch?v=l71dlYe3enM&ab_channel=Unidata) about metpy to calculate the heat index but it still gives me the same error. Here is a piece of my code:

climate_data = "C:/Users/princ/Documents/python code/heatindex/climate.csv" 

dataset = pd.read_csv(climate_data, index_col=0, parse_dates=True)

hu_index = calc.heat_index (dataset["temperature"].values * units.degC, dataset["humidity"].values * units.percent, mask_undefined = False)

enter image description here

corp_guy
  • 35
  • 5
  • Can you include the code you use to read in your data? My guess is it's netCDF and you're using netcdf4-python? Otherwise, what version of MetPy are you using? – DopplerShift May 05 '21 at 17:20
  • @DopplerShift I have edited my post with the code to read my data. I am reading a CSV. I am using metpy 1.0 – corp_guy May 06 '21 at 12:31
  • Can you include the text of the full error traceback above? Also, can you share the data file somewhere? – DopplerShift May 06 '21 at 17:34
  • @DopplerShift I have added the full traceback error in the question. Here is the link to access the csv file "https://drive.google.com/file/d/1MJupJxoxmQJ4R4lcUVoc1BlrQrsQ64XM/view?usp=sharing" – corp_guy May 07 '21 at 06:33

1 Answers1

1

MetPy takes advantage of the NumPy default __array_function__ interface for applying calculations to pint quantities (units!). This check became default as of NumPy 1.17 and was optional with the environment variable NUMPY_EXPERIMENTAL_ARRAY_FUNCTION=1 set in NumPy 1.16.

The quickest way for you to fix this would be to update NumPy to 1.17 or newer, but if you need NumPy<1.17 then set the above environment variable to get this working!

dcamron
  • 155
  • 5