Skip to content
Snippets Groups Projects
Commit 835a0611 authored by Dethinne Thomas's avatar Dethinne Thomas
Browse files

Upload New File

parent 13665e4f
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
"""
Created on Fri Apr 26 09:50:43 2024
@author: Thomas
"""
#
# ----------------------------------------------------------------------------------------------------------------------
#
# Create C02 and tprev file for CARAIB
#
# ----------------------------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------------
#
# Imports and global variables
# \**********************************/
#
import numpy as np
import time
import xarray as xr
import os
import sys
import matplotlib.pyplot as plt
import shutil
# ----------------------------------------------------------------------------------------------------------------------
#
# Functions
# \***************/
#
#
# Here you can define usefull functions to be used in the main
#
"""##############################################################################################################"""
def ti():
return time.time()
"""##############################################################################################################"""
def open_mar(path):
return xr.open_mfdataset(path+"*.nc")
"""##############################################################################################################"""
def main_tprev(ys):
# Copy the file
shutil.copy('./temyyyy.dat.txt', f'./tem{ys}.dat')
"""##############################################################################################################"""
def main_co2(ys,ye):
dict_co2= {1850:284.317,
1851:284.451,
1852:284.598,
1853:284.731,
1854:284.846,
1855:284.941,
1856:285.049,
1857:285.204,
1858:285.369,
1859:285.545,
1860:285.739,
1861:285.933,
1862:286.100,
1863:286.271,
1864:286.442,
1865:286.614,
1866:286.781,
1867:286.955,
1868:287.105,
1869:287.225,
1870:287.355,
1871:287.494,
1872:287.664,
1873:287.860,
1874:288.061,
1875:288.291,
1876:288.520,
1877:288.752,
1878:288.993,
1879:289.221,
1880:289.470,
1881:289.737,
1882:290.019,
1883:290.263,
1884:290.512,
1885:290.797,
1886:291.100,
1887:291.414,
1888:291.763,
1889:292.113,
1890:292.458,
1891:292.816,
1892:293.167,
1893:293.477,
1894:293.791,
1895:294.079,
1896:294.365,
1897:294.646,
1898:294.954,
1899:295.300,
1900:295.675,
1901:296.007,
1902:296.325,
1903:296.654,
1904:296.954,
1905:297.289,
1906:297.662,
1907:298.098,
1908:298.518,
1909:298.936,
1910:299.377,
1911:299.829,
1912:300.353,
1913:300.910,
1914:301.419,
1915:301.937,
1916:302.485,
1917:303.011,
1918:303.449,
1919:303.814,
1920:304.246,
1921:304.600,
1922:304.945,
1923:305.271,
1924:305.630,
1925:305.813,
1926:305.954,
1927:306.177,
1928:306.329,
1929:306.495,
1930:306.620,
1931:306.822,
1932:307.093,
1933:307.402,
1934:307.785,
1935:308.227,
1936:309.012,
1937:309.764,
1938:310.294,
1939:310.851,
1940:311.357,
1941:311.811,
1942:312.172,
1943:312.390,
1944:312.413,
1945:312.385,
1946:312.390,
1947:312.486,
1948:312.521,
1949:312.632,
1950:312.821,
1951:313.014,
1952:313.342,
1953:313.730,
1954:314.095,
1955:314.415,
1956:314.698,
1957:314.992,
1958:315.345,
1959:315.807,
1960:316.625,
1961:317.299,
1962:318.044,
1963:318.650,
1964:319.332,
1965:319.815,
1966:320.880,
1967:321.479,
1968:322.388,
1969:323.250,
1970:324.783,
1971:325.400,
1972:327.349,
1973:329.909,
1974:330.756,
1975:330.827,
1976:331.545,
1977:333.352,
1978:335.009,
1979:336.604,
1980:338.705,
1981:340.059,
1982:340.644,
1983:342.266,
1984:344.007,
1985:345.459,
1986:346.903,
1987:348.774,
1988:351.275,
1989:352.893,
1990:354.072,
1991:355.352,
1992:356.228,
1993:356.925,
1994:358.254,
1995:360.239,
1996:362.005,
1997:363.252,
1998:365.933,
1999:367.845,
2000:369.125,
2001:370.673,
2002:372.835,
2003:375.411,
2004:376.987,
2005:378.907,
2006:381.010,
2007:382.603,
2008:384.739,
2009:386.280,
2010:388.717,
2011:390.944,
2012:393.016,
2013:395.725,
2014:397.547,
2015:399.948,
2016:403.116,
2017:405.793,
2018:408.760,
2019:411.789,
2020:414.891,
2021:418.064,
2022:421.334,
2023:424.720,
2024:428.220,
2025:431.830,
2026:435.550,
2027:439.377,
2028:443.315,
2029:447.360,
2030:451.514,
2031:455.778,
2032:460.163,
2033:464.682,
2034:469.330,
2035:474.111,
2036:479.025,
2037:484.071,
2038:489.252,
2039:494.566,
2040:500.018,
2041:505.607,
2042:511.341,
2043:517.227,
2044:523.266,
2045:529.460,
2046:535.809,
2047:542.314,
2048:548.976,
2049:555.799,
2050:562.783,
2051:569.929,
2052:577.258,
2053:584.783,
2054:592.506,
2055:600.429,
2056:608.549,
2057:616.869,
2058:625.390,
2059:634.113,
2060:643.041,
2061:652.171,
2062:661.506,
2063:671.044,
2064:680.788,
2065:690.739,
2066:700.898,
2067:711.268,
2068:721.850,
2069:732.647,
2070:743.661,
2071:754.892,
2072:766.322,
2073:777.929,
2074:789.718,
2075:801.690,
2076:813.847,
2077:826.192,
2078:838.727,
2079:851.451,
2080:864.368,
2081:877.479,
2082:890.708,
2083:903.980,
2084:917.301,
2085:930.671,
2086:944.091,
2087:957.566,
2088:971.095,
2089:984.680,
2090:998.320,
2091:1012.019,
2092:1025.739,
2093:1039.449,
2094:1053.149,
2095:1066.849,
2096:1080.529,
2097:1094.209,
2098:1107.889,
2099:1121.549,
2100:1135.209,
}
for yy in np.arange(ys,ye+1):
text = ""
f = open(f"./co2prev{yy}.res", "a")
for x in np.arange(0,20,1):
text = text + "\t"+str(round(float(dict_co2[yy]),3))
text = text + "\n"
f.write(text)
f.close()
f.close()
# Main
# \**********/
#
#
# Here you can define the instructions that are called when you execute this file
#
if __name__ == '__main__':
t0=ti()
ys = 2009 #starting year -1
ye = 2015 #end year
# main_tprev(ys)
main_co2(ys,ye)
t1=ti()
print('Programme compiled in ',t1-t0, 'sec')
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment