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

Add method to find bad coadds #260

Open
Catarina-Alves opened this issue Mar 25, 2022 · 0 comments
Open

Add method to find bad coadds #260

Catarina-Alves opened this issue Mar 25, 2022 · 0 comments
Labels
feature To add a new feature, new standalone files. (High level)

Comments

@Catarina-Alves
Copy link
Collaborator

In previous versions of SNANA (before March/2022), the simlibs coadds were not working properly; not all the observations in the same night of the same passband were coadded. I made a function to check if a sndata dataset suffers from this issue. It would be great to add it to the base class in sndata.

Code:

def find_bad_coadd(dataset):
    obj_names = dataset.object_names[:3]
    pbs = dataset.filter_set
    number_obs_per_night = []
    for i in np.arange(len(obj_names)):
        obj = obj_names[i]
        obj_data = dataset.data[obj]
        
        for pb in pbs:
            is_pb = obj_data['filter'] == pb
            obj_data_pb = obj_data[is_pb]
            obj_mjd_pb = np.array(obj_data_pb['mjd'])
            
            time_diff = obj_mjd_pb[1:] - obj_mjd_pb[:-1]
            index_change_night = np.where(time_diff >.5)[0] + 1

            number_obs_per_night_obj = np.zeros(len(index_change_night) + 1)
            number_obs_per_night_obj[0] = index_change_night[0]
            number_obs_per_night_obj[1:-1] = index_change_night[1:] - index_change_night[:-1]
            number_obs_per_night_obj[-1] = len(obj_mjd_pb) - index_change_night[-1]
            
            # we expect one visit per night in each passband, so subtract it
            number_obs_per_night_obj -= 1
            if np.sum(number_obs_per_night_obj) > 0:
                print(obj, pb)
                print(number_obs_per_night_obj)
                sys.exit('It should have only one visit per night in each filter.')
    print('No repeats')
@Catarina-Alves Catarina-Alves added the feature To add a new feature, new standalone files. (High level) label Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature To add a new feature, new standalone files. (High level)
Projects
None yet
Development

No branches or pull requests

1 participant