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

Change input file formats and input paths in chilled #29

Draft
wants to merge 55 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
01de126
Add CSV versions of input archetype files
measrainsey Oct 15, 2024
46a8ac2
Update functions to read in CSVs and condense functions
measrainsey Oct 15, 2024
b8271ab
Modify input parameters of updated function
measrainsey Oct 15, 2024
d2da3ff
Update parameters of function
measrainsey Oct 15, 2024
a8b31e6
Add CSV files for `dle_coolssp` version
measrainsey Oct 15, 2024
77078c1
Add CSV input files for `test` version
measrainsey Oct 15, 2024
f083caf
Remove Excel files for `ALPS2023` version
measrainsey Oct 15, 2024
f0062ac
Remove Excel files for `dle_coolssp` version
measrainsey Oct 15, 2024
9ec16d5
Remove Excel files for `test` version
measrainsey Oct 15, 2024
7d861b6
Change `read_excel` to `read_csv`
measrainsey Oct 16, 2024
7bc8668
Fix naming in arch input of `dle_coolssp` scenario
measrainsey Oct 16, 2024
c7f3293
Add arch input data for `low` arch
measrainsey Oct 16, 2024
c041c82
Remove path setting in config
measrainsey Oct 22, 2024
884681d
Add function to set paths based on user
measrainsey Oct 22, 2024
9497a78
Update path setting in other scripts
measrainsey Oct 22, 2024
b728bf3
Add second version string to correct data path
measrainsey Oct 22, 2024
4e78f3f
Fix path name typo
measrainsey Oct 22, 2024
4595c5c
Update paths to use `get_paths()` in preprocessing
measrainsey Oct 31, 2024
96da133
Save postprocessed CHILLED data
measrainsey Oct 22, 2024
50d1cf6
Merge pull request #34 from iiasa/chilled/upd-post
measrainsey Oct 31, 2024
6e173c7
Merge pull request #32 from iiasa/chilled/upd-paths
measrainsey Oct 31, 2024
f406a31
Rename `chilled.util.util` to `chilled.util.base`
measrainsey Oct 31, 2024
b7bd7f2
Move `get_logger()` and `get_project_root()` to new `chilled.util.com…
measrainsey Oct 31, 2024
8d340e9
Change logging from FileHandler() to StreamHandler() on stdout
measrainsey Oct 31, 2024
75bca5d
Add Literal options in config
measrainsey Dec 18, 2024
94ac6d9
Fix Literal options for popfix
measrainsey Dec 18, 2024
1415f2e
Create version for ALPS2024 (copied over from ALPS2023)
measrainsey Dec 19, 2024
5fa2514
Turn on both cooling and heating in config as default
measrainsey Dec 19, 2024
19a3dd8
Replace `config.chunk_size` with `get_paths(config, chunk_size)`
measrainsey Dec 19, 2024
fd2b17f
Change path that preprocess rasters are saved to
measrainsey Dec 19, 2024
772dd43
Add input data for ALPS2024 version with only heating
measrainsey Dec 19, 2024
a4a9543
Add script to run just heating
measrainsey Dec 19, 2024
dfcff62
Bring back variables lost to linting
measrainsey Dec 19, 2024
af71628
Add script to only process ISO tables
measrainsey Dec 19, 2024
1165ba9
Add other functions back
measrainsey Dec 19, 2024
1537281
Move run_iso.py file
measrainsey Dec 19, 2024
3589696
Turn off cooling in run_iso.py
measrainsey Dec 19, 2024
92e6b83
Remove Nd filter from calculation of E_h
measrainsey Dec 19, 2024
7f72a15
Fix issue with df_cool being needed when heat == 1
measrainsey Dec 20, 2024
acd5861
Only run `process_iso_tables()` function
measrainsey Dec 20, 2024
3e5cec0
Update functions to aggregate all GCM-RCP data
measrainsey Jan 7, 2025
7516491
Move aggregate functions
measrainsey Jan 7, 2025
faf9d04
Change `run_agg.py` to be run after all GCM-RCP combos
measrainsey Jan 7, 2025
7226ed3
Replace `pyam.cumulative` with `pyam.timeseries.cumulative`
measrainsey Jan 7, 2025
bd4c6d3
Create output paths if they do not exist already
measrainsey Jan 7, 2025
9644f0e
Run prereg data for cooling and heating separately
measrainsey Jan 7, 2025
d1126b1
Set cool = 0 and heat = 1
measrainsey Jan 7, 2025
7b39daa
Fix bug of E_c_ac_popwei being in heating
measrainsey Jan 7, 2025
2bd5994
Separate creating prereg data into cooling and heating
measrainsey Jan 7, 2025
8e86bce
Add example script for extracting city data from rasters
measrainsey Jan 13, 2025
d2fdae8
Add script to apply emulation
measrainsey Jan 15, 2025
74dc389
Add script to run emulator
measrainsey Jan 15, 2025
2f1582f
Comment out logs
measrainsey Jan 15, 2025
54f02f8
Remove `exclude` column
measrainsey Jan 15, 2025
63ebca4
Fix `file_str` being used in filenames
measrainsey Jan 15, 2025
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
328 changes: 0 additions & 328 deletions message_ix_buildings/chilled/analysis/aggregate.py

This file was deleted.

51 changes: 51 additions & 0 deletions message_ix_buildings/chilled/cities/example_coords.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import numpy as np
import pandas as pd
import xarray as xr

# Load example temperature data
temp_file = "/Volumes/mengm.pdrv/watxene/ISIMIP/ISIMIP3b/InputData/climate_updated/bias-adjusted/ssp126/GFDL-ESM4/gfdl-esm4_r1i1p1f1_w5e5_ssp126_tas_global_daily_2015_2020.nc"

# Read the temperature data
temp = xr.open_dataarray(temp_file)

# Example: List of city coordinates (lat, lon)
city_coords = [
(51.5074, -0.1278), # London
(40.7128, -74.0060), # New York
(35.6895, 139.6917), # Tokyo
]

# Convert to a pandas DataFrame for clarity
city_df = pd.DataFrame(city_coords, columns=["lat", "lon"])

# Step 1: Stack lat and lon into a single dimension 'locations'
stacked_temp = temp.stack(locations=("lat", "lon"))

# Step 2: Find the nearest indices manually by calculating the distances
selected_points = []
for _, row in city_df.iterrows():
lat, lon = row["lat"], row["lon"]
print("city: " + str(lat) + ", " + str(lon))

# Find the nearest index by calculating the distance between each point
# and the given coordinates
dist = np.sqrt((stacked_temp.lat - lat) ** 2 + (stacked_temp.lon - lon) ** 2)
nearest_idx = dist.argmin() # index of the nearest point

# Select the nearest point based on the index
nearest_point = stacked_temp.isel(locations=nearest_idx)

# Add lat, lon as coordinates as city_lat, city_lon
nearest_point["city_location"] = "(" + str(lat) + ", " + str(lon) + ")"
nearest_point["city_lat"] = lat
nearest_point["city_lon"] = lon

# Append the selected point to the list
selected_points.append(nearest_point)

# Step 3: Concatenate the selected points into a single 1D xarray
selected_vector = xr.concat(selected_points, dim="locations")

# Display results as a 1D array or convert to pandas DataFrame if preferred
df = selected_vector.to_dataframe().reset_index()
print(df)
Loading