-
Notifications
You must be signed in to change notification settings - Fork 3
Add fitting light curve #505
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
base: master
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
# Conflicts: # ztf_viewer/model_fit.py
for more information, see https://pre-commit.ci
# Conflicts: # ztf_viewer/model_fit.py
for more information, see https://pre-commit.ci
# Conflicts: # ztf_viewer/pages/viewer.py
hombit
left a comment
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.
Pre-approve it so deployment would run
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.
Could you please update this file from the master branch?
ztf_viewer/model_fit.py
Outdated
|
|
||
|
|
||
| class ModelFit: | ||
| base_url = "http://host.docker.internal:8000/api/v1" |
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.
This should be a configurable URL
ztf_viewer/model_fit.py
Outdated
| ], | ||
| "ebv": ebv, | ||
| "name_model": fit_model, | ||
| "redshift": [0.05, 0.3], |
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.
Sounds too arbitrary, should be at least class-level attribute, at most a parameter.
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 added Target class
ztf_viewer/model_fit.py
Outdated
| json={ | ||
| "parameters": params, | ||
| "name_model": name_model, | ||
| "zp": 8.9, |
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.
We have ABZPMAG_JY for that
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 fixed it
ztf_viewer/model_fit.py
Outdated
| return params | ||
|
|
||
| def get_curve(self, df, dr, ref_mag_values, bright, params, name_model): | ||
| path = "/sncosmo/get_curve" |
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.
Should be a class/object attribute
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 added a path in ModelFit and a function to set it.
ztf_viewer/model_fit.py
Outdated
| self._api_session = requests.Session() | ||
|
|
||
| def fit(self, df, fit_model, ref_mag_values, dr, ebv): | ||
| path = "/sncosmo/fit" |
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.
Should be a class/object attribute
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 fixed it
ztf_viewer/model_fit.py
Outdated
| if not ref_mag_values: | ||
| oid_ref = {} | ||
| try: |
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 don't really understand this part of the code.
- What
ref_mag_valuessupposed to be? True/False? Or None/dict? If the least, than you never use that dict, and also please change the statement to more explicit:if ref_mag_values is not None. - If the catalog not available, you
passand never use the references. It is not a good behavior, because the result will change without user's consent, and do it implicitly without any notification. Maybe it is better to just fail, than do that - You are mutating the input dataframe. It is not a good practice, what if the caller would reuse it? Please do something like
df = df.copy()if you want to change the values.
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 removed ref_mag_values and took into account the unavailability of getting a ref, and now I'm not changing the input dataframe.
ztf_viewer/model_fit.py
Outdated
| ] | ||
| except (NotFound, CatalogUnavailable): | ||
| pass | ||
| res_fit = requests.post( |
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 the expected behavior if it fails? I think we normally catch it and raise a CatalogUnavailable error, which can be processed in the UI code.
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 took into account the unavailability of getting a ref
ztf_viewer/pages/viewer.py
Outdated
| else: | ||
| raise ValueError(f"{lc_type = } is unknown") | ||
| if name_model and fit_params: | ||
| df_fit = model_fit.get_curve(df, dr, ref_mag_values, bright, json.loads(fit_params), name_model) |
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 if it fails? We would lose the whole plot I guess...
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 fixed it
for more information, see https://pre-commit.ci
No description provided.