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

Set the default timestamps in config file #259

Merged
merged 3 commits into from
Jan 16, 2020
Merged

Set the default timestamps in config file #259

merged 3 commits into from
Jan 16, 2020

Conversation

morcuended
Copy link
Member

@morcuended morcuended commented Jan 15, 2020

In order to be able to use any of the three available timestamps for pointing interpolation, I propose these changes (suggested by @rlopezcoto). I do not know if the nomenclature is the most convenient or not.

  • Add the timestamps_pointing variable in the standard config file
  • Use the timestamps defined in the config file (either ucts, dragon or tib) for pointing interpolation instead of having one of them hardcoded.

In this way, it will be possible to analyze old data using the required timestamps without having to change the code each time.

 - Add the timestamp_pointing variable in the standard config file
 - Use the timestamps set in the config file for poinintg interpolation
@rlopezcoto
Copy link
Contributor

Thanks @morcuended!
Just for the record and what you told us by mail: this addition to the config file will allow to use dragon time for the data taken in November and ucts in the one taken from now on.

@morcuended
Copy link
Member Author

Thanks @morcuended!
Just for the record and what you told us by mail: this addition to the config file will allow to use dragon time for the data taken in November and ucts in the one taken from now on.

Yes, that's it

Commenting it with @labsaha we realized that probably is better to define three variables in the config file like:

"ucts_timestamps_pointing": "true"
"dragon_timestamps_pointing": "false"
"tib_timestamps_pointing": "false"

because one might not know the names of the variables (ucts, dragon, tib), which are only written in the dl0_to_dl1.py script. Thus the code would instead look like this:

# Select the timestamps to be used for pointing interpolation
if config['ucts_timestamps_pointing']:
    event_timestamps = ucts_time                                                                                     
elif config['dragon_timestamps_pointing']:                                                                    
    event_timestamps = dragon_time                                                                                      
elif config['tib_timestamps_pointing']:                                                                        
    event_timestamps = tib_time   

What do you think @rlopezcoto?

@rlopezcoto
Copy link
Contributor

I think it is a good idea, but I also see it a bit dangerous because if more than one of the variables are set as true in the config file, the selection may be overwritten. You can maybe add a line throwing an error if more than one of the time stamps have been selected.

@vuillaut
Copy link
Member

vuillaut commented Jan 15, 2020

I think it is a good idea, but I also see it a bit dangerous because if more than one of the variables are set as true in the config file, the selection may be overwritten. You can maybe add a line throwing an error if more than one of the time stamps have been selected.

I agree with @rlopezcoto here.
In this case, we don't know what is the default one in case everything is set to True (by mistake).

The general question is "should the standard config file be exhaustive about the options?"
to which I would reply no and that this is the role of the documentation. But ahem, you see where this is getting us, that would require a documentation 🙃

(note that this question is not limited to the option at hand here)

ps: I would personally keep the current impementation, but it's as you prefer, both options have their flaws.

event_timestamps = dragon_time
elif config['timestamps_pointing'] == "tib":
event_timestamps = tib_time

Copy link
Member

Choose a reason for hiding this comment

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

else:
    raise ValueError("the timestamps_pointing option is not a valid one")

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, @vuillaut!
The error should be raised whenever there is more than one timestamp option set as true, right? So first we have to check this.

We were thinking of rather creating a timestamps_pointing dictionary within config file. It would look like this:

"timestamps_pointing":{
    "ucts": true
    "dragon": false
    "tib": false
}

and check whether there is more than one true element with something like this:
list(filter(config["timestamps_pointing"].get, config["timestamps_pointing"]))
So it would be:

if len(list(filter(config["timestamps_pointing"].get,
                   config["timestamps_pointing"]))) > 1:
    raise ValueError("the timestamps_pointing option is not a valid one")

But it's quite the opposite of explicit. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

else:
    raise ValueError("the timestamps_pointing option is not a valid one")

OK, I didn't quite understand yesterday when I saw it first. Now I also prefer the first implementation with the addition of these (else & raise) lines. Makes the code clearer. With the second implementation, it wouldn't be so clear how to raise the error, because it has to be checked whether there is only one true option or not.

@morcuended morcuended requested a review from vuillaut January 16, 2020 09:26
@rlopezcoto
Copy link
Contributor

ok, everything looks good now, thanks @morcuended and @vuillaut! If nobody else opposes, I'll also merge

@rlopezcoto rlopezcoto merged commit ae42939 into cta-observatory:master Jan 16, 2020
@morcuended morcuended deleted the default_time_to_configfile branch January 16, 2020 16:42
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.

3 participants