Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update starlog #491

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

update starlog #491

wants to merge 5 commits into from

Conversation

mtremmel
Copy link
Contributor

@mtremmel mtremmel commented Oct 6, 2018

in order to handle the possible inclusion of an extra data column in the starlog file (tcoolform).

@@ -1204,9 +1228,9 @@ def __init__(self, filename, sort=True, paramfile=None):
'f8', 'f8', 'f8',
'f8', 'f8', 'f8',
'f8', 'f8', 'f8')})
moledH = False
Copy link
Member

Choose a reason for hiding this comment

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

Why is this moledH?

Suggested change
moledH = False
moledC = False

@emapple
Copy link
Contributor

emapple commented Sep 10, 2020

This PR is a bit old, but can it still be incorporated? We're working with some simulations that have tcoolform in the starlog and it would be nice if the master branch of pynbody could handle it

@mtremmel
Copy link
Contributor Author

Thanks for the ping on this @emapple. I've updated the branch to be up to date with pynbody's master branch. I've also fixed the bug that @apontzen pointed out above. Sorry for having this fall off the radar. Please try out this pull request branch and let me know if you have issues. In particular, I'm not sure if this will play nice with 64 bit integer Iords.

Copy link
Contributor

@emapple emapple left a comment

Choose a reason for hiding this comment

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

@mtremmel I have included two specific changes. With them, I think it plays well with 64-bit iords. I'll note this isn't totally consistent with recent commits to pynbody. Namely, a recent PR adds an attempt to read in starlog metadata from the log file before. I suspect changes in that commit conflict with changes in this one, so it'll take some care to make sure the conflicts are resolved properly.

@@ -943,6 +943,8 @@ def read_starlog(self, fam=None):
#b(sl)['velform'] = sl['vel'][:len(self.star), :]
if 'h2form' in sl.star.keys():
b(b(b(sl))).star['h2form'] = b(b(sl)).star['h2form']
if 'tcoolform' in sl.star.keys():
b(b(b(sl))).star['tcoolform'] = b(b(sl)).star['tcoolform']
else: print "No H2 data found in StarLog file"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this else statement is supposed to be above the 'tcoolform' if statement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I should just remove these print statements all together... plus they aren't compatible with python3 anyway as they are now I don't think

Copy link
Contributor

Choose a reason for hiding this comment

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

@apontzen previously asked me to convert all of these prints to logger.info, but I haven't gotten around to it yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they weren't necessary so I removed them.

"x", "y", "z",
"vx", "vy", "vz",
"massform", "rhoform", "tempform", "h2form"),
'formats': ('i4', 'i4', 'f8',
Copy link
Contributor

Choose a reason for hiding this comment

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

This branch failed on a read of 64-bit iords for me, and I think it's because this is supposed to introduce 64-bit iords here, and uses 32-bit by mistake. Making the change from i4 to i8 fixed the problem for me locally.

If tcool == True, that means iSize is 104 (4*2 + 8*12) above, but here you've defined file_structure with a size of 96 (2*4 + 8*11). Therefore, here we should have 64-bit iords. This is consistent with the later logger info as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is a bit more complicated than that given all the degeneracies. I've tried to implement a change to fix this and allow for both h2 and tcoolform information with 64-bit iords.

Copy link
Contributor

Choose a reason for hiding this comment

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

That update seems to work.

I thought tcoolform was phased out, and didn't realize there could be both 64-bit iords and tcoolform. I think this effectively solves the problem (though again, I think using the metadata in the log file is ultimately the best solution going forward).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is now, but might not be in your runs. This will hopefully ensure backwards compatibility. The problem is that due to the degeneracy, you may have a mismatch in manes (i.e. tcoolform may be marked as h2form). I also agree, I think this pull request will be unnecessary once we get a good metadata system going (assuming we can convert pre-existing files too)

@trquinn trquinn mentioned this pull request May 30, 2024
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.

None yet

3 participants