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

DM-13685: Add storage of calibrated fluxes and computation of flux means to ap_association #15

Merged
merged 7 commits into from May 15, 2018

Conversation

morriscb
Copy link
Contributor

@morriscb morriscb commented May 4, 2018

No description provided.

Fix bugs in store_dia_sources

Debug test_association_db_sqlite

Add handling of nan values to record test.

Flesh out test_store_ccd_visit_info.

Debug test_association_db_sqlite
Debug test_association_db_sqlite

Fix psFluxMeanErr name

Fix typos
Fix aliasMap bug

Add test for correct schema values in run.

Partially debug test_update_dia_objects
Fix test comparison numbers

Finish unittests for association_tack

Add and edit doc strings and comments.
Copy link
Contributor

@ebellm ebellm left a comment

Choose a reason for hiding this comment

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

Several minor suggestions.

Force the value of diaObjectId for a DIASource.
overwrite_dict : `dict` (optional)
Dictionary of values and keys to overwrite into the values of
source_record and store the values in overwrite_dict instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this docstring

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this better?
overwrite_dict : `dict` (optional) Mapping specifying the names of columns to overwrite with specified values.

# explicitly set it here.
values.append(int(obj_id))
field_name = sub_schema.getField().getName()
overwrite_value = overwrite_dict.get(field_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest instead here:

if field_name in overwrite_dict:
   values.append(overwrite_dict[field_name])

# dateTimeMJD ``seconds``,
# flux zero point ``counts``,
# flux zero point error ``counts``]
values = [visit_info.getExposureId(),
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 would be less fragile to schema changes if you made this a dictionary and then used the keys to specify the columns explicitly in the SQL statement in store_ccd_visit_info above

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've created a new function much like make_minimal_dia_object_schema and the like for the CcdVisitTable. Let me know if this works for you.

insert_string = ("?," * len(values[0]))[:-1]

self._db_cursor.executemany(
"INSERT OR REPLACE INTO %s VALUES (%s)" %
(converter.table_name, insert_string), values)

def get_db_filter_id_from_name(self, filter_name):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe go ahead and make the inverse function now (get_db_filter_name_from_id) to save yourself the trouble the future...

dia_object_record['psFluxMeanErr_%s' % filter_name] = np.nan
else:
fluxes = dia_sources.get("psFlux")[
dia_sources.get('filterId') == filter_id]
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems gross to have to pass in both filter_id and filter_name here.

Could we load the filterMap table into a (not global, but easily accessible) dictionary at runtime so you can always translate back and forth on the fly?

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'm not sure of that's any better. The idea here is these functions could easily be ported somewhere else (for instance meas_algorithms) without too much effort. Adding something like a state variable would make it harder to remove later. I could input a pipe.base.Struct here with the filter name and id but that seems a little convoluted to input just two variables.

@@ -152,27 +190,45 @@ def associate_sources(self, dia_objects, dia_sources):
return match_result.associated_dia_object_ids

@pipeBase.timeMethod
def update_dia_objects(self, updated_obj_ids):
def update_dia_objects(self, dia_objects, updated_obj_ids, exposure):
Copy link
Contributor

Choose a reason for hiding this comment

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

could just pass in filter_name rather than the whole exposure; you can judge if that's an improvement

"""Test that the filter name mapper to id is working.
"""
for filter_name, filter_id in zip(self.assoc_db.config.filter_names,
[0, 1, 2, 3, 4, 5]):
Copy link
Contributor

Choose a reason for hiding this comment

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

automatically generate the ids from len(filter_names)?

Add filter_id to name test

Debug ccdVisit dicts and name to id conversion
@morriscb morriscb merged commit 31de171 into master May 15, 2018
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

2 participants