Merge Will's models - #1
Merged
Merged
Conversation
Includes xarray, numpy, matplotlib, pandas, netCDF4, and ipykernel for running notebooks in the repository.
Simple energy models. Current values for constants such as thermal inertia, heat exchange, etc. are not tuned
2-layer model added which in theory is closest to what we want. Parameters are not tuned
Now uses emissivity and real values for CO2, which are included in the new data subdirectory
There was a problem hiding this comment.
🟡 Changes recommended
The newly added Python script contains syntax/runtime errors (e.g., invalid function definition and datetime handling) that prevent it from running as-is.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds a plotting example script and CO₂ concentration datasets, alongside a pinned Python dependency set to support running the new code/data in this repository.
Changes:
- Adds a new
requirements.txtwith pinned scientific Python dependencies. - Introduces
J01-OLR_ASR_plotexample.pyfor OLR/ASR visualization and (in-progress) IEEI weighting logic. - Adds historical and SSP scenario CO₂ CSV datasets under
data/.
File summaries
| File | Description |
|---|---|
| requirements.txt | Adds pinned Python dependencies for the new analysis/plotting workflow. |
| J01-OLR_ASR_plotexample.py | Adds plotting example code and preliminary IEEI/time-weight utilities. |
| data/co2_ssp_scenarios_2024_2100.csv | Adds projected CO₂ SSP scenario time series for 2024–2100. |
| data/co2_historical_1850_2023.csv | Adds historical CO₂ time series for 1850–2023. |
Review details
Suppressed comments (1)
J01-OLR_ASR_plotexample.py:105
- Month coordinates are 0-11, but xarray's
time.dt.monthis 1-12, so.sel(month=...)will fail (KeyError) for all months.
"month": np.arange(12),
- Files reviewed: 3/8 changed files
- Comments generated: 10
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| import numpy as np | ||
| import matplotlib.pyplot as plt | ||
| import matplotlib as mpl | ||
| import seaborn as sns |
Comment on lines
+17
to
+18
| if ax is None: | ||
| fig, ax = plt.subplots(figsize=(10, 5)) |
| scatter = ax.scatter( | ||
| olr_da, | ||
| asr_da, | ||
| c=olr_da['time.year']+0.083*olr_da['time.month'], #fractional year coordinate |
Comment on lines
+41
to
+56
| # Add a colorbar with discrete intervals and extend='both' keyword | ||
| # bounds = pd.date_range( | ||
| # start=pd.to_datetime(olr_da["time"].min().data), | ||
| # end=pd.to_datetime(olr_da["time"].max().data), | ||
| # periods=min(olr_da.sizes['time'],255)) | ||
| bounds = np.arange( | ||
| olr_da['time.year'].min(), | ||
| olr_da['time.year'].max(), | ||
| max(1,(olr_da['time.year'].max()-olr_da['time.year'].min())/255)) | ||
| norm = mpl.colors.BoundaryNorm(np.array(bounds), cmap.N, extend='both') | ||
|
|
||
| plt.colorbar( | ||
| mpl.cm.ScalarMappable(norm=norm, cmap=cmap), | ||
| ax=ax, orientation='vertical', | ||
| label="Time", | ||
| ) |
| return fig, ax | ||
|
|
||
|
|
||
| def compute IEEI( |
| """ | ||
| Compute the integrated earth's energy imbalance (IEEI) from ASR and OLR fields. | ||
| """ | ||
| assert olr_ds["time"] == asr_ds["time"], "OLR and ASR time fields are not identical" |
| data=seconds_per_month, | ||
| dims=["month"], | ||
| coords={ | ||
| "month": np.arange(12), |
Comment on lines
+109
to
+126
| time_weights = [] | ||
| if account_for_leap == False: | ||
| for _t in time_ds: | ||
| time_weights.append(weights.sel(month=_t['time.month'])) | ||
| else: | ||
| for _t in time_ds: | ||
| if _t["time.year"] % 4 == 0: | ||
| time_weights.append(weights_leap.sel(month=_t['time.month'])) | ||
| else: | ||
| time_weights.append(weights.sel(month=_t['time.month'])) | ||
|
|
||
| # Duplicate the time dimension but with weights as values | ||
| weights_ds = xr.DataArray( | ||
| data=time_weights, | ||
|
|
||
| ) | ||
|
|
||
| return time_weights |
Comment on lines
+133
to
+134
|
|
||
| return weights.sel(month=time_step['time.month']) |
Comment on lines
+145
to
+146
| olr_da=xr.DataArray(olr, dims=["time"], coords={"time": np.arange(len(olr))}), | ||
| asr_da=xr.DataArray(asr, dims=["time"], coords={"time": np.arange(len(asr))}), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.