Skip to content

Commit

Permalink
Merge pull request #4 from NOAA-Strausz/master
Browse files Browse the repository at this point in the history
Rounding decimal places for csv output
  • Loading branch information
shaunwbell authored Aug 9, 2018
2 parents 926924d + 0f8a195 commit 8440aa7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ARGOS_service_data_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ def get_data(fobj=None):
parse_dates=[['year','doy','hhmm']],date_parser=argo_to_datetime)

df['longitude']=df['longitude'] * -1 #convert to +W

df['longitude']=df.longitude.round(3)
df['latitude']=df.latitude.round(3)


df.set_index(pd.DatetimeIndex(df['year_doy_hhmm']),inplace=True)
#df.drop('year_doy_hhmm',axis=1,inplace=True)

Expand Down Expand Up @@ -151,7 +154,7 @@ def __init__(self, missing=1e35):
self.missing = missing

@staticmethod
def get_data(fobj=None, time='current'):
def get_data(fobj=None):
r"""
Basic Method to open files. Specific actions can be passes as kwargs for instruments
Expand Down Expand Up @@ -493,7 +496,13 @@ def pandas2netcdf(df=None,ofile='data.nc'):

"""------------------------ output options----------------------"""
if args.csv:
df['longitude']=df.longitude.apply(lambda x: "%.3f" % x )
df['latitude']=df.latitude.apply(lambda x: "%.3f" % x )
df['sst']=df.sst.apply(lambda x: "%.2f" % x)
df['strain']=df.strain.apply(lambda x: "%.1f" % x)
df['voltage']=df.voltage.apply(lambda x: "%.1f" % x)
df.to_csv(args.csv)


if args.netcdf:
pandas2netcdf(df=df,ofile=args.netcdf)
Expand Down

0 comments on commit 8440aa7

Please sign in to comment.