You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have confirmed this bug exists on the lastest release of atlite.
I have confirmed this bug exists on the current master branch of atlite.
Issue Description
Hi all,
I am having issues to create atlitle cutouts with the Sarah module. The time resolution (dt) of the .nc files from Sarah is defined as "H", while atlite is looking for cutout.dt in ("30min", "30T", "h", "1h"). I have tried to modify the .nc files by opening each one with xarray and modify the "timefreq" attribute to "1h", so that atlite detects it. When I chech the attributes of the modified .nc files, I see that "timefreq" is set as "1h". However, when trying to do the atlite cutout, time resolution still shows as "H". I am working with instantaneous SIS and SID downloaded data from Sarah for the month of january 2013 and in Europe, and I downloaded and extracted all the files as explained in https://atlite.readthedocs.io/en/latest/examples/create_cutout_SARAH.html. I would appreciate some input on how to fix this bug. Thanks.
Reproducible Example
# I am trying somethingimportloggingimportatliteimportxarrayasxrlogging.basicConfig(level=logging.INFO)
importcdsapic=cdsapi.Client()
importosimportglobimportxarrayasxr# Original directory containing your SARAH NetCDF filessarah_dir=r"C:/Users/marta/Desktop/Thesis/Climate-Change-Impacted-Solar-Energy-Generation/atlite examples/sarah2"# New directory where fixed files will be savedsarah_dir_fixed=r"C:/Users/marta/Desktop/Thesis/Climate-Change-Impacted-Solar-Energy-Generation/atlite examples/sarah2_fixed"# Ensure the new directory existsos.makedirs(sarah_dir_fixed, exist_ok=True)
# Pattern to find all .nc files in the original directoryfile_pattern=os.path.join(sarah_dir, "*.nc")
# Loop over each NetCDF file in the directoryforfile_pathinglob.glob(file_pattern):
print(f"Processing: {file_path}")
# Open the datasetds=xr.open_dataset(file_path)
# Update or set the 'timefreq' attribute to "1h"ds.attrs["timefreq"] ="1h"# Optional resampling if needed# ds = ds.resample(time="1H").nearest()# Build a new filename in the 'sarah2_fixed' directory# e.g. if file_path = ".../sarah2/file1.nc", # we create ".../sarah2_fixed/file1_fixed.nc"base_name=os.path.splitext(os.path.basename(file_path))[0]
new_file_path=os.path.join(sarah_dir_fixed, base_name+"_fixed.nc")
# Save the modified datasetds.to_netcdf(new_file_path)
# Close the datasetds.close()
print(f"Saved fixed file to: {new_file_path}")
print("All NetCDF files processed!")
cutout=atlite.Cutout(
path="europe-2013-01.nc",
module=["sarah", "era5"],
sarah_dir="C:/Users/marta/Desktop/Thesis/Climate-Change-Impacted-Solar-Energy-Generation/atlite examples/sarah2_fixed",
x=slice(-13.6913, 1.7712),
y=slice(49.9096, 60.8479),
time="2013-01",
)
print(f"Time resolution (dt): {cutout.dt}")
cutout.prepare()
Expected Behavior
Atlite should be able to prepare the cutout with time resolution of SARAH but it is not.
Installed Versions
atlite-0.4.0
The text was updated successfully, but these errors were encountered:
Version Checks (indicate both or one)
I have confirmed this bug exists on the lastest release of atlite.
I have confirmed this bug exists on the current
master
branch of atlite.Issue Description
Hi all,
I am having issues to create atlitle cutouts with the Sarah module. The time resolution (dt) of the .nc files from Sarah is defined as "H", while atlite is looking for cutout.dt in ("30min", "30T", "h", "1h"). I have tried to modify the .nc files by opening each one with xarray and modify the "timefreq" attribute to "1h", so that atlite detects it. When I chech the attributes of the modified .nc files, I see that "timefreq" is set as "1h". However, when trying to do the atlite cutout, time resolution still shows as "H". I am working with instantaneous SIS and SID downloaded data from Sarah for the month of january 2013 and in Europe, and I downloaded and extracted all the files as explained in https://atlite.readthedocs.io/en/latest/examples/create_cutout_SARAH.html. I would appreciate some input on how to fix this bug. Thanks.
Reproducible Example
Expected Behavior
Atlite should be able to prepare the cutout with time resolution of SARAH but it is not.
Installed Versions
The text was updated successfully, but these errors were encountered: