I want to convert an array of date-time strings (YYYY-MM-DD hh:mm:ss) to GPS seconds (seconds after 2000-01-01 12:00:00) in the python environment.
In order to get the GPS seconds for a single date in Linux BASH, I simply input date2sec datetimestring and it returns a number.
I could do this within a for-loop within python. But, how would I incorporate this within the python script, as it is an external script?
Or, is there another way to convert an array of date-time strings (or single date-time strings incorporated into a for-loop) to GPS time without using date2sec?
Updated Answer: uses Astropy library:
Here you are setting the date in UTC and
t.gpsconverts the datetime to GPS seconds.Further research showed that directly using datetime objects doesn't take leap seconds into account.
other helpful links here: How to get current date and time from GPS unsegment time in python