From 70db11d6f68cbea0c1755520ec96ca6cd9c7e88f Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Wed, 30 Jan 2019 15:22:17 +0800 Subject: clusters/main: Improve keys handling in _save_halos_data() This also fixes the issue when try to remove a non-existent key. --- fg21sim/extragalactic/clusters/main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'fg21sim/extragalactic/clusters') diff --git a/fg21sim/extragalactic/clusters/main.py b/fg21sim/extragalactic/clusters/main.py index e174db3..d1cb11d 100644 --- a/fg21sim/extragalactic/clusters/main.py +++ b/fg21sim/extragalactic/clusters/main.py @@ -494,9 +494,8 @@ class GalaxyClusters: os.rename(outfile, outfile+".old") logger.info("Converting halos data into a Pandas DataFrame ...") - keys = list(self.halos[0].keys()) - for k in ["gamma", "spectrum", "spectrum_fiducial", "template"]: - keys.remove(k) + keys_ignored = ["gamma", "spectrum", "spectrum_fiducial", "template"] + keys = [k for k in self.halos[0].keys() if k not in keys_ignored] halos_df = dictlist_to_dataframe(self.halos, keys=keys) dataframe_to_csv(halos_df, outfile, clobber=clobber) logger.info("Saved halos data to CSV file: %s" % outfile) -- cgit v1.2.2