-
Notifications
You must be signed in to change notification settings - Fork 18
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
Making n sub intervals a config class parameter #1090
Merged
Little-Ryugu
merged 3 commits into
main
from
making-n_sub_intervals-a-config-class-parameter
Jan 11, 2025
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,9 @@ class simulationConfigs: | |
ar_healpix_order: int = None | ||
"""the order of healpix which we will use for the healpy portions of the code.""" | ||
|
||
n_sub_intervals: int = None | ||
"""Number of sub-intervals for the Lagrange ephemerides interpolation (default: 101)""" | ||
|
||
_ephemerides_type: str = None | ||
"""Simulation used for ephemeris input.""" | ||
|
||
|
@@ -111,6 +114,7 @@ def _validate_simulation_configs(self): | |
self.ar_fov_buffer = cast_as_float(self.ar_fov_buffer, "ar_fov_buffer") | ||
self.ar_picket = cast_as_int(self.ar_picket, "ar_picket") | ||
self.ar_healpix_order = cast_as_int(self.ar_healpix_order, "ar_healpix_order") | ||
self.n_sub_intervals = cast_as_int_or_set_default(self.n_sub_intervals, "n_sub_intervals", 101) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To keep the same format. I'd make the variable ar_n_sub_intervals There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (edited above to fix my typo) |
||
elif self._ephemerides_type == "external": | ||
# makes sure when these are not needed that they are not populated | ||
check_key_doesnt_exist(self.ar_ang_fov, "ar_ang_fov", "but ephemerides type is external") | ||
|
@@ -1307,6 +1311,39 @@ def cast_as_bool_or_set_default(value, key, default): | |
return default | ||
|
||
|
||
def cast_as_int_or_set_default(value, key, default): | ||
|
||
# replaces PPGetBoolOrExit: checks to make sure the value can be cast as a bool. | ||
""" | ||
Checks to see if value can be cast as an int and if not set (equals None) gives default int. | ||
|
||
Parameters | ||
----------- | ||
value : object attribute | ||
value of the config file attribute | ||
|
||
key : string | ||
The key being checked. | ||
|
||
default : int | ||
default int if value is None | ||
|
||
Returns | ||
---------- | ||
value as an int | ||
""" | ||
|
||
if value is not None: | ||
try: | ||
int(value) | ||
except ValueError: | ||
logging.error(f"ERROR: expected an int for config parameter {key}. Check value in config file.") | ||
sys.exit(f"ERROR: expected an int for config parameter {key}. Check value in config file.") | ||
return value | ||
elif value is None: | ||
return default | ||
|
||
|
||
def PrintConfigsToLog(sconfigs, cmd_args): | ||
""" | ||
Prints all the values from the config file and command line to the log. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why can't you just do
self.n_sub_intervals = 101 # we set this to a default 101?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matthewholman any particular reason we hide the n_sub_intervals from the configuration file but all the healpix order to be changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the latest updates we can expose to the user which is how @Little-Ryugu is implementing it but it would default to 101? If we keep it this way, @Little-Ryugu I don't think you need a new function is there a way to use cast_as_int or check if it's none (like the trailing loss flag which is only sometimes used) and then set the value to the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no reason to hide that from the user, as long as there is a default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this parameter so I can add it to the documentation @matthewholman ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was afraid you would ask. That is the number of sub-intervals used in evaluating a Lagrange interpolation function to make sure fast-movers are not missed. It's pretty arbitrary.