Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fixes: 1. Interpolation of missing data, 2. Spelling error: CLI file #56

Merged
merged 3 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/rat/cli/rat_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def main():
dest='global_data_dir',
required=False
)
run_parser.add_argument(
configure_parser.add_argument(
'-nc', '--n_cores',
help='Number of cores to use for executing RAT',
action='store',
Expand Down
18 changes: 11 additions & 7 deletions src/rat/data_processing/metsim_input_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,20 @@ def _read(self):
self.winds[day, :, :] = wind
# pbar.update(1)

# Imputes missing data by interpolation in the order of dimensions time, lon, lat.
def _impute_basin_missing_data(self, combined_data):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add self as an argument

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added argument 'self'

combine_nomiss_data = combined_data.where(combined_data['extent']==1,-9999)
combine_nomiss_data = combined_data
try:
combine_nomiss_data = combine_nomiss_data.interpolate_na(dim="time", method="linear", fill_value="extrapolate")
#Interpolation using time dimension - if unsuccesful values will still be NaN
combine_nomiss_data = combine_nomiss_data.interpolate_na(dim="time", method="linear", fill_value="extrapolate", limit = 30)
#Interpolation using lon dimension - if unsuccesful values will still be NaN
combine_nomiss_data = combine_nomiss_data.interpolate_na(dim="lon", method="linear", fill_value="extrapolate")
#Interpolation using lat dimension - if unsuccesful values will still be NaN
combine_nomiss_data = combine_nomiss_data.interpolate_na(dim="lat", method="linear", fill_value="extrapolate", use_coordinate=False)
except:
try:
combine_nomiss_data = combine_nomiss_data.interpolate_na(dim="lon", method="linear", fill_value="extrapolate")
except:
print("No inter or extra polation can be done.")
combine_nomiss_data = combine_nomiss_data.where(combine_nomiss_data!=-9999,combined_data)
print("No inter or extra polation is possible.")
#Restoring original values outside basin extent. This ensures that ocean tiles remain to be NaN/-9999
combine_nomiss_data = combine_nomiss_data.where(combined_data['extent']==1,combined_data)
return combine_nomiss_data

def _write(self):
Expand Down