|
| 1 | +import re |
| 2 | + |
| 3 | +to_rewrite = """Experiment short name | Experiment description | Anthropogenic Forcing | Volcanic Forcing | Solar Forcing | Start Year | End Year | Main purpose |
| 4 | +-- | -- | -- | -- | -- | -- | -- | -- |
| 5 | +amip | Atmosphere with SSTs and SICs prescribed | Time-varying | Time-varying | Time-varying | 1979 | 2021 | Evaluation, SST/sea ice forced variability |
| 6 | +piControl and/or esm-piControl | Coupled atmosphere-ocean pre-industrial control | All 1850, CO2 prescribed concentration or zero emissions | Fixed mean radiative forcing matching historical simulation (i.e. 1850–2021 mean) | Fixed mean value matching first two solar cycles of the historical simulation (i.e. 1850–1873 mean) | 1 | 400+ | Evaluation, unforced variability |
| 7 | +abrupt- 4xCO2 | CO2 prescribed to 4 times preindustrial | Same as piControl except CO2 concentration prescribed to 4 times piControl | Same as piControl | Same as piControl | 1 (branching from year 101 or later of piControl) | 300+ (1000) | Equilibrium climate sensitivity, feedback, fast responses |
| 8 | +1pctCO2 | CO2 prescribed to increase at 1% yr-1 | Same as piControl except CO2 prescribed to increase at 1% yr-1 | Same as piControl | Same as piControl | 1 (branching from year 101 or later of piControl) | 150 | Transient climate sensitivity |
| 9 | +historical and/or esm-hist | Simulation of the recent past | All time varying, CO2 prescribed concentration or emission | Time varying | Time varying | 1850 | 2021 | Evaluation |
| 10 | +piClim-Control (amip) | Preindustrial conditions including SST and SIC prescribed | All 1850, CO2 prescribed concentration | Same as piControl | Same as piControl | 1 | 30 | Baseline for model-specific effective radiative forcing (ERF) calculations |
| 11 | +piClim-anthro (amip) | As piClim-Control except present-day anthropogenic forcing | All 2021, CO2 prescribed concentration | Same as piControl | Same as piControl | 1 | 30 | Quantify present-day total anthropogenic ERF |
| 12 | +piClim-4xCO2 (amip) | As piClim-Control except CO2 concentrations set to 4 times preindustrial | All 1850 except CO2 prescribed at 4 times preindustrial concentration | Same as piControl | Same as piControl | 1 | 30 | Quantify ERF of 4 × CO2 |
| 13 | +""" |
| 14 | + |
| 15 | + |
| 16 | +def remove_double_space(v: str) -> str: |
| 17 | + if " " not in v: |
| 18 | + return v |
| 19 | + |
| 20 | + return remove_double_space(v.replace(" ", " ").replace("\t", "")) |
| 21 | + |
| 22 | + |
| 23 | +grid = [] |
| 24 | +for line in to_rewrite.split("\n"): |
| 25 | + if not line: |
| 26 | + continue |
| 27 | + |
| 28 | + start = re.sub(r"\s", " ", line.strip()) |
| 29 | + cells = [remove_double_space(v.strip()) for v in start.split("|")] |
| 30 | + grid.append(cells) |
| 31 | + |
| 32 | +col_widths = [] |
| 33 | +for col in range(len(grid[0])): |
| 34 | + col_values = [grid[row][col] for row in range(len(grid))] |
| 35 | + col_widths.append(max(len(v) for v in col_values)) |
| 36 | + |
| 37 | +out_l = [] |
| 38 | +for row in range(len(grid)): |
| 39 | + if row == 1: |
| 40 | + row_underlines = ["-" * col_widths[col] for col in range(len(col_widths))] |
| 41 | + out_l.append(" | ".join(row_underlines)) |
| 42 | + continue |
| 43 | + |
| 44 | + entries = [grid[row][col].ljust(col_widths[col]) for col in range(len(col_widths))] |
| 45 | + out_l.append(" | ".join(entries)) |
| 46 | + |
| 47 | + |
| 48 | +out = "\n".join(out_l) |
| 49 | +print(out) |
0 commit comments