Ensure float precision is limited when outputting csv

Without this change, interim .csv files were being recorded with 9 decimal places, greatly increasing the file size. This keeps the number of decimals limited to a practical amount.
develop
Chris Leaman 6 years ago
parent 9e3716480a
commit 1fca122276

@ -422,6 +422,6 @@ def create_twl_forecast(
profile_type=profile_type, profile_type=profile_type,
) )
df_twl.to_csv(output_file) df_twl.to_csv(output_file, float_format="%.4f")
logger.info("Saved to %s", output_file) logger.info("Saved to %s", output_file)
logger.info("Done!") logger.info("Done!")

@ -140,6 +140,6 @@ def create_forecasted_impacts(profile_features_csv, forecasted_twl_csv, output_f
right_on=["site_id"], right_on=["site_id"],
) )
df_forecasted_impacts.to_csv(output_file) df_forecasted_impacts.to_csv(output_file, float_format="%.4f")
logger.info("Saved to %s", output_file) logger.info("Saved to %s", output_file)
logger.info("Done!") logger.info("Done!")

@ -467,8 +467,8 @@ def create_waves_csv(waves_mat, sites_csv, waves_output_file, sites_waves_output
df_waves.set_index(["site_id", "datetime"], inplace=True) df_waves.set_index(["site_id", "datetime"], inplace=True)
df_waves.sort_index(inplace=True) df_waves.sort_index(inplace=True)
df_waves, df_sites_waves = split_site_wave_params(df_waves) df_waves, df_sites_waves = split_site_wave_params(df_waves)
df_waves.to_csv(waves_output_file) df_waves.to_csv(waves_output_file, float_format="%.4f")
df_sites_waves.to_csv(sites_waves_output_file) df_sites_waves.to_csv(sites_waves_output_file, float_format="%.4f")
logger.info("Created %s", waves_output_file) logger.info("Created %s", waves_output_file)
logger.info("Created %s", sites_waves_output_file) logger.info("Created %s", sites_waves_output_file)
@ -523,9 +523,9 @@ def create_sites_and_profiles_csv(
df_sites.set_index(["site_id"], inplace=True) df_sites.set_index(["site_id"], inplace=True)
df_sites.sort_index(inplace=True) df_sites.sort_index(inplace=True)
df_profiles.to_csv(profiles_output_file) df_profiles.to_csv(profiles_output_file, float_format="%.8f")
logger.info("Created %s", profiles_output_file) logger.info("Created %s", profiles_output_file)
df_sites.to_csv(sites_output_file, float_format="%.3f") df_sites.to_csv(sites_output_file, float_format="%.8f")
logger.info("Created %s", sites_output_file) logger.info("Created %s", sites_output_file)
@ -542,7 +542,7 @@ def create_tides_csv(tides_mat, sites_csv, output_file):
df_tides = replace_unique_sites(df_tides, df_sites) df_tides = replace_unique_sites(df_tides, df_sites)
df_tides.set_index(["site_id", "datetime"], inplace=True) df_tides.set_index(["site_id", "datetime"], inplace=True)
df_tides.sort_index(inplace=True) df_tides.sort_index(inplace=True)
df_tides.to_csv(output_file) df_tides.to_csv(output_file, float_format="%.4f")
logger.info("Created %s", output_file) logger.info("Created %s", output_file)

Loading…
Cancel
Save