{ "cells": [ { "cell_type": "markdown", "id": "6e8c5c25-687b-4e45-8455-a759f27a2b1d", "metadata": {}, "source": [ "in the merged folder I copied all data from v3 into v2. This leads to the \"valid\" csv to only reflect v3. Need to merge this." ] }, { "cell_type": "code", "execution_count": 3, "id": "f776df0e-2529-46ec-be15-6c661d91b70c", "metadata": {}, "outputs": [], "source": [ "import glob\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 4, "id": "20a3ec31-2dec-4314-a682-5ecfe26a01a2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "v2/output_agg_upscaled/RGI01/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI02/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI03/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI04/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI05/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI06/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI07/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI08/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI09/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI10/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI11/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI12/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI13/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI14/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI15/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI16/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI17/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI18/hypercube_valid.csv\n", "v2/output_agg_upscaled/RGI19/hypercube_valid.csv\n" ] } ], "source": [ "# Pattern to match files, e.g., \"*.txt\" for all text files\n", "pattern = \"v2/output_agg_upscaled/**/hypercube_valid.csv\"\n", "\n", "# Find all files recursively\n", "files = sorted(glob.glob(pattern, recursive=True))\n", "\n", "# Print the matched files\n", "for file in files:\n", " print(file)" ] }, { "cell_type": "code", "execution_count": 27, "id": "3db480a0-b08d-464b-96e1-846b3fb79ad5", "metadata": {}, "outputs": [], "source": [ "for file in files:\n", " dfv2 = pd.read_csv(file, index_col=0)\n", " dfv3 = pd.read_csv(file.replace('v2', 'v3'), index_col=0)\n", " \n", " dfo = pd.concat([dfv2, dfv3[dfv3.columns[5:]]], axis=1)\n", " sorted_cols = list(dfo.columns[:5]) + sorted(dfo.columns[5:])\n", " dfo = dfo[sorted_cols]\n", " \n", " of = file.replace('v2', 'merged_v2v3')\n", " dfo.to_csv(of)" ] }, { "cell_type": "code", "execution_count": 10, "id": "0e7f0a0a-d65d-4a97-ad7d-74b58618db44", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['valid_IPSL-CM6A-LR_ssp534-over', 'valid_MRI-ESM2-0_ssp534-over',\n", " 'valid_CESM2-WACCM_ssp126', 'valid_CESM2-WACCM_ssp585',\n", " 'valid_CESM2-WACCM_ssp534-over'],\n", " dtype='object')" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [] }, { "cell_type": "code", "execution_count": 8, "id": "174a94e9-8300-4727-a2a8-ea1d3306226c", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | melt_f | \n", "temp_bias | \n", "prcp_fac | \n", "temp_melt | \n", "glen_a | \n", "valid_IPSL-CM6A-LR_ssp126 | \n", "valid_IPSL-CM6A-LR_ssp585 | \n", "valid_MRI-ESM2-0_ssp126 | \n", "valid_MRI-ESM2-0_ssp585 | \n", "
---|---|---|---|---|---|---|---|---|---|
exp | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
0 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "0.977888 | \n", "0.978098 | \n", "0.977977 | \n", "0.978098 | \n", "
1 | \n", "0.422340 | \n", "-1.006530 | \n", "1.692046 | \n", "2.001025 | \n", "2.129014 | \n", "0.471724 | \n", "0.943878 | \n", "0.532711 | \n", "0.952051 | \n", "
2 | \n", "-0.222516 | \n", "2.352821 | \n", "0.844443 | \n", "-1.413166 | \n", "0.276735 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "
3 | \n", "0.445820 | \n", "-1.165183 | \n", "1.727352 | \n", "2.709390 | \n", "0.774872 | \n", "0.377674 | \n", "0.941106 | \n", "0.416018 | \n", "0.942735 | \n", "
4 | \n", "0.690500 | \n", "-0.557530 | \n", "1.372393 | \n", "-1.765897 | \n", "1.399388 | \n", "0.977948 | \n", "0.978061 | \n", "0.977985 | \n", "0.978098 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
296 | \n", "1.366163 | \n", "1.086176 | \n", "1.229347 | \n", "-2.299781 | \n", "0.546946 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "
297 | \n", "-0.520724 | \n", "-1.524965 | \n", "1.235378 | \n", "-1.497855 | \n", "1.430720 | \n", "0.964977 | \n", "0.977689 | \n", "0.976124 | \n", "0.977699 | \n", "
298 | \n", "-1.580318 | \n", "-1.205472 | \n", "0.962362 | \n", "-0.900769 | \n", "0.214041 | \n", "0.971459 | \n", "0.976450 | \n", "0.975032 | \n", "0.976492 | \n", "
299 | \n", "1.505797 | \n", "-2.192723 | \n", "0.939824 | \n", "2.078779 | \n", "0.603272 | \n", "0.933173 | \n", "0.975783 | \n", "0.939236 | \n", "0.976252 | \n", "
300 | \n", "-0.088527 | \n", "1.549439 | \n", "0.699100 | \n", "-1.064418 | \n", "4.968703 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "
301 rows × 9 columns
\n", "\n", " | melt_f | \n", "temp_bias | \n", "prcp_fac | \n", "temp_melt | \n", "glen_a | \n", "valid_CESM2-WACCM_ssp126 | \n", "valid_CESM2-WACCM_ssp534-over | \n", "valid_CESM2-WACCM_ssp585 | \n", "valid_IPSL-CM6A-LR_ssp126 | \n", "valid_IPSL-CM6A-LR_ssp534-over | \n", "valid_IPSL-CM6A-LR_ssp585 | \n", "valid_MRI-ESM2-0_ssp126 | \n", "valid_MRI-ESM2-0_ssp534-over | \n", "valid_MRI-ESM2-0_ssp585 | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
exp | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
0 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "0.978061 | \n", "0.978061 | \n", "0.978098 | \n", "0.977888 | \n", "0.977898 | \n", "0.978098 | \n", "0.977977 | \n", "0.978016 | \n", "0.978098 | \n", "
1 | \n", "0.422340 | \n", "-1.006530 | \n", "1.692046 | \n", "2.001025 | \n", "2.129014 | \n", "0.672373 | \n", "0.673006 | \n", "0.961328 | \n", "0.471724 | \n", "0.472019 | \n", "0.943878 | \n", "0.532711 | \n", "0.615209 | \n", "0.952051 | \n", "
2 | \n", "-0.222516 | \n", "2.352821 | \n", "0.844443 | \n", "-1.413166 | \n", "0.276735 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "
3 | \n", "0.445820 | \n", "-1.165183 | \n", "1.727352 | \n", "2.709390 | \n", "0.774872 | \n", "0.502460 | \n", "0.459006 | \n", "0.957520 | \n", "0.377674 | \n", "0.383990 | \n", "0.941106 | \n", "0.416018 | \n", "0.448302 | \n", "0.942735 | \n", "
4 | \n", "0.690500 | \n", "-0.557530 | \n", "1.372393 | \n", "-1.765897 | \n", "1.399388 | \n", "0.978061 | \n", "0.978061 | \n", "0.978098 | \n", "0.977948 | \n", "0.977948 | \n", "0.978061 | \n", "0.977985 | \n", "0.978016 | \n", "0.978098 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
296 | \n", "1.366163 | \n", "1.086176 | \n", "1.229347 | \n", "-2.299781 | \n", "0.546946 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "
297 | \n", "-0.520724 | \n", "-1.524965 | \n", "1.235378 | \n", "-1.497855 | \n", "1.430720 | \n", "0.977221 | \n", "0.977212 | \n", "0.977754 | \n", "0.964977 | \n", "0.973309 | \n", "0.977689 | \n", "0.976124 | \n", "0.976848 | \n", "0.977699 | \n", "
298 | \n", "-1.580318 | \n", "-1.205472 | \n", "0.962362 | \n", "-0.900769 | \n", "0.214041 | \n", "0.976137 | \n", "0.976173 | \n", "0.976471 | \n", "0.971459 | \n", "0.972644 | \n", "0.976450 | \n", "0.975032 | \n", "0.975661 | \n", "0.976492 | \n", "
299 | \n", "1.505797 | \n", "-2.192723 | \n", "0.939824 | \n", "2.078779 | \n", "0.603272 | \n", "0.949689 | \n", "0.949155 | \n", "0.976377 | \n", "0.933173 | \n", "0.934914 | \n", "0.975783 | \n", "0.939236 | \n", "0.943451 | \n", "0.976252 | \n", "
300 | \n", "-0.088527 | \n", "1.549439 | \n", "0.699100 | \n", "-1.064418 | \n", "4.968703 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "0.978098 | \n", "
301 rows × 14 columns
\n", "