|
8 | 8 | import os |
9 | 9 |
|
10 | 10 | def create_era5_compatible_surface(input_path, output_path, target_lat, target_lon): |
11 | | - """Patch ERA5 surface data to be RocketPy-compatible.""" |
| 11 | + """ |
| 12 | + Patch ERA5 surface data to be RocketPy-compatible for RocketPy EnvironmentAnalysis. |
| 13 | +
|
| 14 | + This function loads an ERA5 NetCDF surface file, renames and adds required variables, |
| 15 | + snaps the data to the nearest grid point to the target latitude and longitude, and |
| 16 | + writes the patched dataset to a new NetCDF file. |
| 17 | +
|
| 18 | + Parameters |
| 19 | + ---------- |
| 20 | + input_path : str |
| 21 | + Path to the input ERA5 NetCDF surface file. |
| 22 | + output_path : str |
| 23 | + Path to the output patched NetCDF file. |
| 24 | + target_lat : float |
| 25 | + Target latitude (in degrees) to snap to the nearest grid point. |
| 26 | + target_lon : float |
| 27 | + Target longitude (in degrees) to snap to the nearest grid point. |
| 28 | +
|
| 29 | + Returns |
| 30 | + ------- |
| 31 | + best_lat : float |
| 32 | + Latitude of the nearest grid point to the target latitude. |
| 33 | + best_lon : float |
| 34 | + Longitude of the nearest grid point to the target longitude. |
| 35 | +
|
| 36 | + Raises |
| 37 | + ------ |
| 38 | + FileNotFoundError |
| 39 | + If the input_path does not exist. |
| 40 | + KeyError |
| 41 | + If required variables (e.g., 'u10', 'latitude', 'longitude') are missing from the dataset. |
| 42 | +
|
| 43 | + Example |
| 44 | + ------- |
| 45 | + >>> best_lat, best_lon = create_era5_compatible_surface( |
| 46 | + ... "input_surface.nc", "patched_surface.nc", -23.5, -46.6 |
| 47 | + ... ) |
| 48 | + >>> print(best_lat, best_lon) |
| 49 | + """ |
12 | 50 | print(f"Loading ERA5 surface: {input_path}") |
13 | 51 | ds = xr.open_dataset(input_path) |
14 | 52 |
|
|
0 commit comments