# Path: pygeons/mjd.py
# @_memoize
# def mjd(s,fmt):
#   ''' 
#   Converts a date string into Modified Julian Date (MJD)
#   
#   Parameters
#   ----------
#   s : string
#     Date string
# 
#   fmt : string
#     Format string indicating how to parse *s*
#       
#   Returns
#   -------
#   out : int
#     Modified Julian Date
# 
#   '''
#   d = datetime.strptime(s,fmt)
#   out = (d - _REFERENCE_DATETIME).days
#   return out
# 
# Path: pygeons/io/io.py
# def _remove_extension(f):
# def _unit_string(space_exponent,time_exponent):
# def _common_context(data_list):
# def pygeons_merge(input_files,output_stem=None):
# def pygeons_crop(input_file,start_date=None,stop_date=None,
#                  min_lat=-np.inf,max_lat=np.inf,
#                  min_lon=-np.inf,max_lon=np.inf,
#                  stations=None,output_stem=None):
# def pygeons_toh5(input_text_file,file_type='csv',output_stem=None):
# def pygeons_totext(input_file,output_stem=None):  
# def pygeons_info(input_file):
# 
# Path: pygeons/basemap.py
# def make_basemap(lon,lat,resolution=None):
#   ''' 
#   Creates a transverse mercator projection which is centered about the 
#   given positions. 
# 
#   Modifying this function should be sufficient to change the way that 
#   all map projections are generated in PyGeoNS
#   '''
#   lon = np.asarray(lon)
#   lat = np.asarray(lat)
#   n = lon.shape[0]
#   # the buffer should be the average shortest distance between 
#   # points... but this is good enough
#   lon_buff = max(0.1,lon.ptp()/np.sqrt(n))
#   lat_buff = max(0.1,lat.ptp()/np.sqrt(n))
#   llcrnrlon = min(lon) - lon_buff
#   llcrnrlat = min(lat) - lat_buff
#   urcrnrlon = max(lon) + lon_buff
#   urcrnrlat = max(lat) + lat_buff
#   lon_0 = (llcrnrlon + urcrnrlon)/2.0
#   lat_0 = (llcrnrlat + urcrnrlat)/2.0
#   return Basemap(projection='tmerc',
#                  resolution=resolution,
#                  lon_0 = lon_0,
#                  lat_0 = lat_0,
#                  llcrnrlon = llcrnrlon,
#                  llcrnrlat = llcrnrlat,
#                  urcrnrlon = urcrnrlon,
#                  urcrnrlat = urcrnrlat)


import numpy as np
import matplotlib.pyplot as plt
from pygeons.mjd import mjd
from pygeons.io.io import text_from_dict
from pygeons.basemap import make_basemap
#####################################################################
data = {}
data['id'] = np.array(['A%03d' % i for i in range(Nx)])
data['longitude'] = pos_geo[:,0]
data['latitude'] = pos_geo[:,1]
data['time'] = times
data['east'] = u
data['north'] = v
data['vertical'] = z
data['east_std_dev'] = su
data['north_std_dev'] = sv
data['vertical_std_dev'] = sz
data['time_exponent'] = 0
data['space_exponent'] = 1
text_from_dict('data.csv',data)

# xder
data = {}
data['id'] = np.array(['A%03d' % i for i in range(Nx)])
data['longitude'] = pos_geo[:,0]
data['latitude'] = pos_geo[:,1]
data['time'] = times
data['east'] = dudxdt
data['north'] = dvdxdt
data['vertical'] = dzdxdt
data['east_std_dev'] = np.zeros((Nt,Nx))
data['north_std_dev'] = np.zeros((Nt,Nx))
data['vertical_std_dev'] = np.zeros((Nt,Nx))
data['time_exponent'] = -1
data['space_exponent'] = 0

# Path: pygeons/mjd.py
# @_memoize
# def mjd(s,fmt):
#   ''' 
#   Converts a date string into Modified Julian Date (MJD)
#   
#   Parameters
#   ----------
#   s : string
#     Date string
# 
#   fmt : string
#     Format string indicating how to parse *s*
#       
#   Returns
#   -------
#   out : int
#     Modified Julian Date
# 
#   '''
#   d = datetime.strptime(s,fmt)
#   out = (d - _REFERENCE_DATETIME).days
#   return out
# 
# Path: pygeons/io/io.py
# def _remove_extension(f):
# def _unit_string(space_exponent,time_exponent):
# def _common_context(data_list):
# def pygeons_merge(input_files,output_stem=None):
# def pygeons_crop(input_file,start_date=None,stop_date=None,
#                  min_lat=-np.inf,max_lat=np.inf,
#                  min_lon=-np.inf,max_lon=np.inf,
#                  stations=None,output_stem=None):
# def pygeons_toh5(input_text_file,file_type='csv',output_stem=None):
# def pygeons_totext(input_file,output_stem=None):  
# def pygeons_info(input_file):
# 
# Path: pygeons/basemap.py
# def make_basemap(lon,lat,resolution=None):
#   ''' 
#   Creates a transverse mercator projection which is centered about the 
#   given positions. 
# 
#   Modifying this function should be sufficient to change the way that 
#   all map projections are generated in PyGeoNS
#   '''
#   lon = np.asarray(lon)
#   lat = np.asarray(lat)
#   n = lon.shape[0]
#   # the buffer should be the average shortest distance between 
#   # points... but this is good enough
#   lon_buff = max(0.1,lon.ptp()/np.sqrt(n))
#   lat_buff = max(0.1,lat.ptp()/np.sqrt(n))
#   llcrnrlon = min(lon) - lon_buff
#   llcrnrlat = min(lat) - lat_buff
#   urcrnrlon = max(lon) + lon_buff
#   urcrnrlat = max(lat) + lat_buff
#   lon_0 = (llcrnrlon + urcrnrlon)/2.0
#   lat_0 = (llcrnrlat + urcrnrlat)/2.0
#   return Basemap(projection='tmerc',
#                  resolution=resolution,
#                  lon_0 = lon_0,
#                  lat_0 = lat_0,
#                  llcrnrlon = llcrnrlon,
#                  llcrnrlat = llcrnrlat,
#                  urcrnrlon = urcrnrlon,
#                  urcrnrlat = urcrnrlat)


# Path: demo/demo1/.write_synthetic.py
import numpy as np
import matplotlib.pyplot as plt
from pygeons.mjd import mjd
from pygeons.io.io import text_from_dict
from pygeons.basemap import make_basemap

#####################################################################
data = {}
data['id'] = np.array(['A%03d' % i for i in range(Nx)])
data['longitude'] = pos_geo[:,0]
data['latitude'] = pos_geo[:,1]
data['time'] = times
data['east'] = u
data['north'] = v
data['vertical'] = z
data['east_std_dev'] = su
data['north_std_dev'] = sv
data['vertical_std_dev'] = sz
data['time_exponent'] = 0
data['space_exponent'] = 1
text_from_dict('data.csv',data)

# xder
data = {}
data['id'] = np.array(['A%03d' % i for i in range(Nx)])
data['longitude'] = pos_geo[:,0]
data['latitude'] = pos_geo[:,1]
data['time'] = times
data['east'] = dudxdt
data['north'] = dvdxdt
data['vertical'] = dzdxdt
data['east_std_dev'] = np.zeros((Nt,Nx))
data['north_std_dev'] = np.zeros((Nt,Nx))
data['vertical_std_dev'] = np.zeros((Nt,Nx))
data['time_exponent'] = -1
data['space_exponent'] = 0

text_from_dict('soln.dudx.csv',data)