Skip to content

Conversation

@nihatog
Copy link
Collaborator

@nihatog nihatog commented Feb 3, 2025

No description provided.

@nihatog nihatog requested a review from anschaible February 3, 2025 11:07
anschaible
anschaible previously approved these changes Feb 3, 2025
@anschaible anschaible requested a review from TobiBu February 3, 2025 12:42
Comment on lines 100 to 105
# Define output filename
if config["simulation"]["name"].lower() == "illustris":
output_filename = f"{filepath}{config['simulation']['name']}_id{config['data']['load_galaxy_args']['id']}_snap{config['data']['args']['snapshot']}_{parttype}_subset{config['data']['subset']['use_subset']}.fits"
else: # NIHAO
output_filename = f"{filepath}{config['simulation']['name']}_snap{config['data']['args'].get('snapshot', 'unknown')}_{parttype}_subset{config['data'].get('subset', {}).get('use_subset', 'unknown')}.fits"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this different syntax here? Can't we homogenise it?
why does NIHAO need the .get method?
I would argue for we homogenise this to use the same keywords and loading procedure for both galaxies. If needed we just create an ID field for NIHAO as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Illustris we assume that all keys are present, so we can access them directly. For NIHAO, some keys are missing (snapshot and use_subset), therefore I used .get to provide default values and avoid errors.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use_subset is also present as key for NIHAO

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snapshot: we are currently using 1024 (indicated in the file path name), we can store this as parameter

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that we have not directly the galaxy ID for NIHAO, but we could use the name g2.8e11 or so as galaxy ID in case of NIHAO. There are two ways, we could specify it in the config as key as galaxy id or we extract it from the file name (same for snapshot)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I meant snapshot and galaxy ID are missing, so it led to a keyerror
I'll take a look at how to make it homogeneous.

…e galaxy ID and snapshot from the simulation path)
anschaible
anschaible previously approved these changes Feb 4, 2025
Copy link
Collaborator

@anschaible anschaible left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it is fine to have an helper function to extract the galaxy id and snapshot from the file path. In my opinion, we will not get rid of adjusting the header for each simulation type a bit.

from matplotlib.colors import LogNorm
import os

def extract_info_from_path(sim_path):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks, the only problem I see with this is that it implicitly assumes that path has a part that is snap_.
what do we do if that is not the case?

I have no good idea how to deal with this as it would always be up to the user to specify this, but maybe a better solution is to simply require the user to set in the config the fields
config["data"]["load_galaxy_args"]["id"] config["data"]["args"]["snapshot"]

what do you think?
This would make the fits header independent of the users data paths...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense.
I have updated the implementation, so now the galaxy id and snapshot are taken directly from the config which is now updated. Also in the fits_file.ipynb we can now select if we want to use NIHAO or Illustris. I thought about creating a new fits_file.ipynb just for NIHAO, but since only the config changes, I implemented both in the same ipynb, @TobiBu @anschaible what do you think about that?

@nihatog nihatog requested review from TobiBu and anschaible February 14, 2025 11:20
Copy link
Collaborator

@TobiBu TobiBu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Nice work!

@anschaible anschaible merged commit 5bcd4a7 into main Feb 24, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants