diff options
author | Aaron LI <aly@aaronly.me> | 2019-01-30 15:22:17 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2019-01-30 15:22:17 +0800 |
commit | 70db11d6f68cbea0c1755520ec96ca6cd9c7e88f (patch) | |
tree | d32a1a056fa5ca189939b65170892409ba43a8c9 /fg21sim/extragalactic/clusters | |
parent | abd3c88209ac8107882de7f8a61b5d06bdb3cefa (diff) | |
download | fg21sim-70db11d6f68cbea0c1755520ec96ca6cd9c7e88f.tar.bz2 |
clusters/main: Improve keys handling in _save_halos_data()
This also fixes the issue when try to remove a non-existent key.
Diffstat (limited to 'fg21sim/extragalactic/clusters')
-rw-r--r-- | fg21sim/extragalactic/clusters/main.py | 5 |
1 files changed, 2 insertions, 3 deletions
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) |