hydroframe / subsettools

Subsetting tools and utilities for ParFlow hydrological modeling
https://hydroframesubsettools.readthedocs.io/en/latest/
MIT License
2 stars 2 forks source link

Bug in config_clm #98

Open aktriplett opened 2 months ago

aktriplett commented 2 months ago

I am attaching the traceback for a bug I've started getting. So far I get this error when attempting to subset for HUC02 and HUC0205, I do not get it when I subset for HUC020502 or HUC02050202. It occurs in the function st.config_clm(), and more specifically in _write_land_cover().


ValueError Traceback (most recent call last) Cell In[17], line 1 ----> 1 clm_paths = st.config_clm(ij_bounds, start=start, end=end, dataset=var_ds, write_dir=static_write_dir)

File /home/SHARED/virtual-environments/conda/lib/python3.11/site-packages/subsettools/clm.py:98, in config_clm(ij_bounds, start, end, dataset, write_dir, time_zone) 96 subset_data = get_hf_gridded_data(options) 97 land_cover_data = _reshape_ndarray_to_vegm_format(subset_data) ---> 98 file_path = _write_land_cover(land_cover_data, write_dir) 99 file_paths[file_type] = file_path 100 print("subset vegm")

File /home/SHARED/virtual-environments/conda/lib/python3.11/site-packages/subsettools/clm.py:187, in _write_land_cover(land_cover_data, write_dir) 185 header = "\n".join([heading, " ".join(vegm_col_names)]) 186 file_path = os.path.join(write_dir, "drv_vegm.dat") --> 187 np.savetxt( 188 fname=file_path, 189 X=land_cover_data, 190 delimiter=" ", 191 comments="", 192 header=header, 193 fmt=["%d"] 2 + ["%.6f"] 2 + ["%.2f"] 2 + ["%d"] 19, 194 ) 195 return file_path

File <__array_function__ internals>:200, in savetxt(*args, **kwargs)

File /home/SHARED/virtual-environments/conda/lib/python3.11/site-packages/numpy/lib/npyio.py:1608, in savetxt(fname, X, fmt, delimiter, newline, header, footer, comments, encoding) 1606 for row in X: 1607 try: -> 1608 v = format % tuple(row) + newline 1609 except TypeError as e: 1610 raise TypeError("Mismatch between array dtype ('%s') and " 1611 "format specifier ('%s')" 1612 % (str(X.dtype), format)) from e

ValueError: cannot convert float NaN to integer