Commit 2ca16923 authored by Patrick Wagner's avatar Patrick Wagner

Initial commit

parents
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"## Load required modules\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"import itertools as it\n",
"from pandas import rolling_sum\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3.6.4 | packaged by conda-forge | (default, Dec 23 2017, 16:31:06) \n",
"[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)]\n"
]
}
],
"source": [
"import sys\n",
"print(sys.version)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1948\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/gfs1/work/shkifmwr/_TM/software/miniconda3_20180131/envs/py3_std/bin/ipython:35: FutureWarning: pd.rolling_sum is deprecated for ndarrays and will be removed in a future version\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"1949\n",
"1950\n",
"1951\n",
"1952\n",
"1953\n",
"1954\n",
"1955\n",
"1956\n",
"1957\n",
"1958\n",
"1959\n",
"1960\n",
"1961\n",
"1962\n",
"1963\n",
"1964\n",
"1965\n",
"1966\n",
"1967\n",
"1968\n",
"1969\n",
"1970\n",
"1971\n",
"1972\n",
"1973\n",
"1974\n",
"1975\n",
"1976\n",
"1977\n",
"1978\n",
"1979\n",
"1980\n",
"1981\n",
"1982\n",
"1983\n",
"1984\n",
"1985\n",
"1986\n",
"1987\n",
"1988\n",
"1989\n",
"1990\n",
"1991\n",
"1992\n",
"1993\n",
"1994\n",
"1995\n",
"1996\n",
"1997\n",
"1998\n",
"1999\n",
"2000\n",
"2001\n",
"2002\n",
"2003\n",
"2004\n",
"2005\n",
"2006\n",
"2007\n"
]
}
],
"source": [
"## Load data\n",
"\n",
"wdir=\"/gfs2/work/shkpwagn/ARIANE/VIKING20-K301_Turtle/\"\n",
"figdir=wdir+\"/FIGURES/\"\n",
"\n",
"\n",
"\n",
"fout15C=wdir+\"/DATA/15C_nfloats.nc\"\n",
"fout15C10d=wdir+\"/DATA/15C10d_nfloats.nc\"\n",
"fout10C=wdir+\"/DATA/10C_nfloats.nc\"\n",
"\n",
"\n",
"year1=1948\n",
"year2=1948\n",
"\n",
"n15C=[]\n",
"n15C10d=[]\n",
"n10C=[]\n",
"n15C10d_no10C\n",
"\n",
"\n",
"for year in range(year1,year2+1):\n",
" print(year)\n",
" ifile=wdir+\"/DATA/GS-\"+str(year)+\"/ariane_trajectories_qualitative.nc\"\n",
" ofile15C=wdir+\"/DATA/GS-\"+str(year)+\"/ariane_trajectories_qualitative_15C.nc\"\n",
" ofile10C=wdir+\"/DATA/GS-\"+str(year)+\"/ariane_trajectories_qualitative_10C.nc\"\n",
" ofile15C10d=wdir+\"/DATA/GS-\"+str(year)+\"/ariane_trajectories_qualitative_15C10d.nc\"\n",
"\n",
" data=xr.open_dataset(ifile)\n",
" #index15C=((data['traj_temp']<=15) & (data['nb_output'] < 73)).any('nb_output')\n",
" index10C=((data['traj_temp']<=10) & (data['nb_output'] < 73)).any('nb_output')\n",
" index15C10d=((rolling_sum(((data['traj_temp']<=15) & (data['nb_output'] < 73)).values,2)) == 2).any(axis=0) \n",
" index15C10d=xr.DataArray(index15C10d,dims=('ntraj'))\n",
" \n",
" index15C10d_not10C=(inedx15C10d & ~index10C)\n",
" \n",
" #data15C=data.where(index15C,drop=True)\n",
" #data10C=data.where(index10C,drop=True)\n",
" #data15C10d=data.where(index15C10d,drop=True)\n",
" #data15C10d_no10=data.where(index15C10d,drop=True)\n",
"\n",
" #n15C+=[index15C.sum().values]\n",
" #n15C10d+=[index15C10d.sum().values]\n",
" #n10C+=[index10C.sum().values]\n",
" #n15C10d_no10+=[index15C10d.sum().values]\n",
" \n",
" #Save to file\n",
" #data15C.to_netcdf(ofile15C)\n",
" #data15C10d.to_netcdf(ofile15C10d)\n",
" #data10C.to_netcdf(ofile10C)\n",
"\n",
"#ds15C = xr.Dataset({'ntraj': (['year'], n15C)},coords={'year':np.arange(year1,year2+1)})\n",
"#ds15C10d = xr.Dataset({'ntraj': (['year'], n15C10d)},coords={'year':np.arange(year1,year2+1)})\n",
"#ds10C = xr.Dataset({'ntraj': (['year'], n10C)},coords={'year':np.arange(year1,year2+1)})\n",
"\n",
"#ds15C.to_netcdf(fout15C)\n",
"#ds15C10d.to_netcdf(fout15C10d)\n",
"#ds10C.to_netcdf(fout10C)"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "SSH shkpwagn@bdata2.hlrn.de python_py3_std_/gfs2/work/shkpwagn/NB_WDIR",
"language": "",
"name": "rik_ssh_shkpwagn_bdata2_hlrn_de_python_py3_std_gfs2workshkpwagnnb_wdir"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Once deleted, variables cannot be recovered. Proceed (y/[n])? y\n"
]
}
],
"source": [
"%matplotlib inline\n",
"%reset"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"## Load required modules\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"import itertools as it\n",
"from pandas import rolling_sum\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3.6.4 | packaged by conda-forge | (default, Dec 23 2017, 16:31:06) \n",
"[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)]\n"
]
}
],
"source": [
"import sys\n",
"print(sys.version)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1948\n",
"1949\n",
"1950\n",
"1951\n",
"1952\n",
"1953\n",
"1954\n",
"1955\n",
"1956\n",
"1957\n",
"1958\n",
"1959\n",
"1960\n",
"1961\n",
"1962\n",
"1963\n",
"1964\n",
"1965\n",
"1966\n",
"1967\n",
"1968\n",
"1969\n",
"1970\n",
"1971\n",
"1972\n",
"1973\n",
"1974\n",
"1975\n",
"1976\n",
"1977\n",
"1978\n",
"1979\n",
"1980\n",
"1981\n",
"1982\n",
"1983\n",
"1984\n",
"1985\n",
"1986\n",
"1987\n",
"1988\n",
"1989\n",
"1990\n",
"1991\n",
"1992\n",
"1993\n",
"1994\n",
"1995\n",
"1996\n",
"1997\n",
"1998\n",
"1999\n",
"2000\n",
"2001\n",
"2002\n",
"2003\n",
"2004\n",
"2005\n",
"2006\n",
"2007\n"
]
}
],
"source": [
"## Load data\n",
"\n",
"wdir=\"/gfs2/work/shkpwagn/ARIANE/VIKING20-K301_Turtle/\"\n",
"fout=wdir+\"/DATA/10C_locations.nc\"\n",
"\n",
"year1=1948\n",
"year2=2007\n",
"\n",
"lon=[]\n",
"lat=[]\n",
"\n",
"for year in range(year1,year2+1):\n",
" print(year)\n",
" file=wdir+\"/DATA/GS-\"+str(year)+\"/ariane_trajectories_qualitative_10C.nc\"\n",
" data=xr.open_dataset(file)\n",
" ii=np.argmax(data['traj_temp']<=10,0)\n",
" lon=+data['traj_lon'].load()[ii,:].values\n",
" lat=+data['traj_lat'].load()[ii,:].values\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"lon1=int(lon.min())\n",
"lon2=int(lon.max()+1)\n",
"lat1=int(lat.min())\n",
"lat2=int(lat.max()+1)\n",
"\n",
"d=0.25\n",
"\n",
"xedges=np.arange(lon1,lon2+d,d)\n",
"yedges=np.arange(lat1,lat2+d,d)\n",
"x=xedges[:-1]+d\n",
"y=yedges[:-1]+d\n",
"\n",
"H,xedges,yedges=np.histogram2d(lon,lat,bins=(xedges, yedges))\n",
"ds = xr.Dataset({'hist': (['lat', 'lon'], H.T)},coords={'lat':y,'lon': x})\n",
"\n",
"ds.to_netcdf(fout)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "SSH shkpwagn@bdata2.hlrn.de python_py3_std_/gfs2/work/shkpwagn/NB_WDIR",
"language": "",
"name": "rik_ssh_shkpwagn_bdata2_hlrn_de_python_py3_std_gfs2workshkpwagnnb_wdir"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Once deleted, variables cannot be recovered. Proceed (y/[n])? y\n"
]
}
],
"source": [
"%matplotlib inline\n",
"%reset"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
"## Load required modules\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"import itertools as it\n",
"from pandas import rolling_sum\n"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3.6.4 | packaged by conda-forge | (default, Dec 23 2017, 16:31:06) \n",
"[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)]\n"
]
}
],
"source": [
"import sys\n",
"print(sys.version)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1948\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/gfs1/work/shkifmwr/_TM/software/miniconda3_20180131/envs/py3_std/bin/ipython:24: FutureWarning: pd.rolling_sum is deprecated for ndarrays and will be removed in a future version\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"1949\n",
"1950\n",
"1951\n",
"1952\n",
"1953\n",
"1954\n",
"1955\n",
"1956\n",
"1957\n",
"1958\n",
"1959\n",
"1960\n",
"1961\n",
"1962\n",
"1963\n",
"1964\n",
"1965\n",
"1966\n",
"1967\n",
"1968\n",
"1969\n",
"1970\n",
"1971\n",
"1972\n",
"1973\n",
"1974\n",
"1975\n",
"1976\n",
"1977\n"
]
}
],
"source": [
"## Load data\n",
"\n",
"wdir=\"/gfs2/work/shkpwagn/ARIANE/VIKING20-K301_Turtle/\"\n",
"figdir=wdir+\"/FIGURES/\"\n",
"\n",
"\n",
"year1=1948\n",
"year2=2009\n",
"\n",
"for year in range(year1,year2+1):\n",
" print(year)\n",
" ifile=wdir+\"/DATA/GS-\"+str(year)+\"/ariane_trajectories_qualitative.nc\"\n",
" ofile15C=wdir+\"/DATA/GS-\"+str(year)+\"/ariane_trajectories_qualitative_15C.nc\"\n",
" ofile10C=wdir+\"/DATA/GS-\"+str(year)+\"/ariane_trajectories_qualitative_10C.nc\"\n",
" ofile15C10d=wdir+\"/DATA/GS-\"+str(year)+\"/ariane_trajectories_qualitative_15C10d.nc\"\n",
"\n",
" data=xr.open_dataset(ifile)\n",
" index15C=((data['traj_temp']<=15) & (data['nb_output'] < 72)).any('nb_output')\n",
" index10C=((data['traj_temp']<=10) & (data['nb_output'] < 72)).any('nb_output')\n",
" \n",
" data15C=data.where(index15C,drop=True)\n",
" data10C=data.where(index10C,drop=True)\n",
" \n",
" index15C10d=((rolling_sum(((data15C['traj_temp']<=15) & (data15C['nb_output'] < 72)).values,2)) == 2).any(axis=0) \n",
" index15C10d=xr.DataArray(index15C10d,dims=('ntraj'))\n",
" data15C10d=data15C.where(index15C10d,drop=True)\n",
"\n",
" #Save to file\n",
" data15C.to_netcdf(ofile15C)\n",
" data10C.to_netcdf(ofile10C)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "SSH shkpwagn@bdata2.hlrn.de python_py3_std_/gfs2/work/shkpwagn/NB_WDIR",
"language": "",
"name": "rik_ssh_shkpwagn_bdata2_hlrn_de_python_py3_std_gfs2workshkpwagnnb_wdir"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"## Load required modules\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import xarray as xr\n",
"import itertools as it\n",
"from pandas import rolling_sum\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3.6.4 | packaged by conda-forge | (default, Dec 23 2017, 16:31:06) \n",
"[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)]\n"
]
}
],
"source": [
"import sys\n",
"print(sys.version)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1948\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/gfs1/work/shkifmwr/_TM/software/miniconda3_20180131/envs/py3_std/bin/ipython:34: FutureWarning: pd.rolling_sum is deprecated for ndarrays and will be removed in a future version\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"1949\n",
"1950\n",
"1951\n",
"1952\n",
"1953\n",
"1954\n",
"1955\n",
"1956\n",
"1957\n",
"1958\n",
"1959\n",
"1960\n",
"1961\n",
"1962\n",
"1963\n",
"1964\n",
"1965\n",
"1966\n",
"1967\n",
"1968\n",
"1969\n",
"1970\n",
"1971\n",
"1972\n",
"1973\n",
"1974\n",
"1975\n",
"1976\n",
"1977\n",
"1978\n",
"1979\n",
"1980\n",
"1981\n",
"1982\n",
"1983\n",
"1984\n",
"1985\n",
"1986\n",
"1987\n",
"1988\n",
"1989\n",
"1990\n",
"1991\n",
"1992\n",
"1993\n",
"1994\n",
"1995\n",
"1996\n",
"1997\n",
"1998\n",
"1999\n",
"2000\n",
"2001\n",
"2002\n",
"2003\n",
"2004\n",
"2005\n",
"2006\n",
"2007\n"
]
}
],
"source": [
"## Load data\n",
"\n",
"wdir=\"/gfs2/work/shkpwagn/ARIANE/VIKING20-K301_Turtle/\"\n",