Commit 712f2886 authored by Carl Schreck's avatar Carl Schreck

Automated Daily Commit - Tue Apr 21 12:00:16 EDT 2020

parent 2c507bde
......@@ -9,11 +9,11 @@ import xarray as xr
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import matplotlib.cm as cm
import matplotlib.style
import matplotlib as mpl
import os
import pandas as pd
import numpy as np
import gzip
import cjs # '~carl/lib/python'
def draw_station_data(path, lat_column=1, lon_column=2, data_column=5,
......@@ -79,14 +79,42 @@ def draw_station_type(path, lat_column=1, lon_column=2, time_column=6,
return asc_data
def read_unscaled(path, lat_column=0, lon_column=1, data_column=4,):
with gzip.open(path, mode='rt') as f:
asc_data = pd.read_csv(path, sep=' ', header=None,
skipinitialspace=True)
lat = xr.DataArray(pd.unique(asc_data[lat_column]),
dims='lat', name='lat',
attrs={'long_name': 'Latitude',
'units': 'degrees_north'})
lat = lat.sortby(lat)
lat.assign_coords(lat=lat)
lon = xr.DataArray(pd.unique(asc_data[lon_column]),
dims='lon', name='lon',
attrs={'long_name': 'Longitude',
'units': 'degrees_east'})
lon = lon.sortby(lon)
lon.assign_coords(lon=lon)
data2d = asc_data[data_column].values.reshape(len(lat), len(lon))
data = xr.DataArray(data2d,
coords=[lat, lon], name=var_name,
attrs={'long_name': var_name_to_long_name[var_name],
'units': var_name_to_units[var_name]})
return data
# path = f'{os.environ["DATA_DIR"]}/nclimgrid/imke_figures/02temp-steps/' \
# f'TMAX19890203map.txt'
path = f'{os.environ["DATA_DIR"]}/nclimgrid/imke_figures/02temp-steps/' \
f'TMAX19890203map.txt'
f'TMAX_19890203_D6_A2.pnt.gz'
bounds=np.arange(-30, 35, 5)
cmap = cm.get_cmap('bwr', lut=(len(bounds) + 1))
norm = mpl.colors.BoundaryNorm(bounds, cmap.N, clip=False)
station_plot = draw_station_type(path, cmap=cmap, norm=norm)
# station_plot = draw_station_type(path, cmap=cmap, norm=norm)
# station_plot = draw_station_type(path)
# plt.colorbar(station_plot)
plt.show()
\ No newline at end of file
# plt.show()
data = read_unscaled(path)
\ No newline at end of file
......@@ -48,13 +48,13 @@ nrows = 621
lon = xr.DataArray((xllcorner + (np.arange(ncols) * cellsize)),
dims='lon', name='lon',
attrs={'long_name': 'Longitude',
'units': 'degrees_north'})
'units': 'degrees_east'})
lon.assign_coords(lon=lon)
lat = xr.DataArray((yllcorner + (np.arange(nrows) * cellsize)),
dims='lat', name='lat',
attrs={'long_name': 'Latitude',
'units': 'degrees_east'})
'units': 'degrees_north'})
lat.assign_coords(lat=lat)
last_day = calendar.monthrange(year, month)[1]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment