From f8afa458cf4e3c9267d614c409db09c87b4b5c12 Mon Sep 17 00:00:00 2001 From: Sharon Fitzpatrick Date: Wed, 20 Sep 2023 22:40:12 -0700 Subject: [PATCH] save metadata as json not pkl --- src/coastsat/SDS_download.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/coastsat/SDS_download.py b/src/coastsat/SDS_download.py index 71b0003..e4658cc 100644 --- a/src/coastsat/SDS_download.py +++ b/src/coastsat/SDS_download.py @@ -664,12 +664,9 @@ def retrieve_images( # once all images have been downloaded, load metadata from .txt files metadata = get_metadata(inputs) - # save metadata dict - with open( - os.path.join(im_folder, inputs["sitename"] + "_metadata" + ".pkl"), "wb" - ) as f: - pickle.dump(metadata, f) + metadata_json = os.path.join(im_folder, inputs["sitename"] + "_metadata" + ".json") + SDS_preprocess.write_to_json(metadata_json, metadata) print("Satellite images downloaded from GEE and save in %s" % im_folder) return metadata @@ -741,11 +738,13 @@ def get_metadata(inputs): metadata[satname]["epsg"].append(epsg) metadata[satname]["dates"].append(date) - # save a .pkl file containing the metadata dict - with open( - os.path.join(filepath, inputs["sitename"] + "_metadata" + ".pkl"), "wb" - ) as f: - pickle.dump(metadata, f) + # save a json file containing the metadata dict + metadata_json = os.path.join(filepath, inputs["sitename"] + "_metadata" + ".json") + SDS_preprocess.write_to_json(metadata_json, metadata) + # with open( + # os.path.join(filepath, inputs["sitename"] + "_metadata" + ".pkl"), "wb" + # ) as f: + # pickle.dump(metadata, f) return metadata