cpalfonso / stellar-data-mining

Scripts to extract subduction-related data for mineral exploration data mining
1 stars 1 forks source link

calculate_erodep error - Data Missing? #2

Open RichardScottOZ opened 2 months ago

RichardScottOZ commented 2 months ago

Just running as is on a ubuntu machine this time: - first extract data notebook

post magnetic

image

coregistered_data = calculate_erodep(
    coregistered_data,
    input_dir=erodep_dir,
    n_jobs=n_jobs,
    column_name="erosion (m)",
    verbose=verbose,
)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[40], line 1
----> 1 coregistered_data = calculate_erodep(
      2     coregistered_data,
      3     input_dir=erodep_dir,
      4     n_jobs=n_jobs,
      5     column_name="erosion (m)",
      6     verbose=verbose,
      7 )

File ~/data/stellar-data-mining/lib/erodep/_extract_erodep.py:296, in calculate_erodep(data, input_dir, weighted, radius, n_jobs, metric, column_name, clip, verbose)
    294     except Exception as err:
    295         print("\n", end="", flush=True)
--> 296         raise err
    297 data = data.join(erodep_col)
    298 if clip:

File ~/data/stellar-data-mining/lib/erodep/_extract_erodep.py:275, in calculate_erodep(data, input_dir, weighted, radius, n_jobs, metric, column_name, clip, verbose)
    273     point_erodep = np.full(data_age.shape[0], 0.0)
    274 else:
--> 275     total_erodep = extract_erodep(
    276         time=age,
    277         dir=input_dir,
    278     )
    279     lats, lons = extract_lat_lon(dir=input_dir)
    280     point_erodep, neigh = interpolate_values(
    281         lons=data_age["present_lon"],
    282         lats=data_age["present_lat"],
   (...)
    290         metric=metric,
    291     )

File ~/data/stellar-data-mining/lib/erodep/_extract_erodep.py:67, in extract_erodep(time, dir)
     65 if time < 0.0:
     66     raise ValueError(f"Invalid time: {time}")
---> 67 timestep_total = _erodep_timestep(time=time, dir=dir)
     68 if time == 0.0:
     69     return timestep_total

File ~/data/stellar-data-mining/lib/erodep/_extract_erodep.py:87, in _erodep_timestep(time, dir, dt)
     84 erodep_times = np.array(sorted(erodep_times))
     85 valid_times = erodep_times[time > erodep_times]
---> 87 erodep_time = np.max(valid_times)
     88 filename = filename_from_time(erodep_time, dir=dir)
     89 with xr.open_dataset(filename) as dset:

File ~/miniconda3/envs/sdm/lib/python3.12/site-packages/numpy/core/fromnumeric.py:2810, in max(a, axis, out, keepdims, initial, where)
   2692 @array_function_dispatch(_max_dispatcher)
   2693 @set_module('numpy')
   2694 def max(a, axis=None, out=None, keepdims=np._NoValue, initial=np._NoValue,
   2695          where=np._NoValue):
   2696     """
   2697     Return the maximum of an array or maximum along an axis.
   2698 
   (...)
   2808     5
   2809     """
-> 2810     return _wrapreduction(a, np.maximum, 'max', axis, None, out,
   2811                           keepdims=keepdims, initial=initial, where=where)

File ~/miniconda3/envs/sdm/lib/python3.12/site-packages/numpy/core/fromnumeric.py:88, in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
     85         else:
     86             return reduction(axis=axis, out=out, **passkwargs)
---> 88 return ufunc.reduce(obj, axis, dtype, out, **passkwargs)

ValueError: zero-size array to reduction operation maximum which has no identity
RichardScottOZ commented 2 months ago
Working on 1 Maextract erodep TIME: 1
source_data/ErosionDeposition
[]
ERODEP_TIMES: set() 

Looking into that function - no ErosionDeposition folder in the source_data download?

RichardScottOZ commented 2 months ago

Should update code to use this one by default -> @brmather ? https://zenodo.org/records/11239167

brmather commented 2 months ago

I think so. My understanding is that Zenodo record corresponds to v1.2 in this repo.