opihiexarata.library.conversion module

For miscellaneous conversions.

opihiexarata.library.conversion.current_utc_to_julian_day() float[source]

Return the current UTC time when this function is called as a Julian day time.

Parameters:

None

Returns:

current_jd – The current time in Julian date format.

Return type:

float

opihiexarata.library.conversion.datetime_timezone_1_to_timezone_2(from_datetime: datetime | str, from_timezone: str, to_timezone: str) datetime[source]

This function converts a date time from one timezone to another timezone.

If the datetime provided is a string of an ISO 8601 time, we convert it, otherwise, we raise. The timezones provided can be any IANA timezone.

Parameters:
  • from_datetime (datetime or str) – The data time, or string representation of one to convert.

  • from_timezone (str) – The timezone which date_time is currently in.

  • to_timezone (str) – The timezone which we are converting to.

Returns:

to_datetime – The datetime after the conversion.

Return type:

datetime

opihiexarata.library.conversion.decimal_day_to_julian_day(year: int, month: int, day: float)[source]

A function to convert decimal day time formats to the Julian day.

Parameters:
  • year (int) – The year of the time stamp to be converted.

  • month (int) – The month of the time stamp to be converted.

  • day (float) – The day of the time stamp to be converted, may be decimal, the values are just passed down.

Returns:

julian_day – The Julian day of the date provided.

Return type:

float

opihiexarata.library.conversion.degrees_per_second_to_arcsec_per_second(degree_per_second: float) float[source]

This converts from degrees per second to arcseconds per second.

Parameters:

degree_per_second (float) – The value, in degrees per second, which you want to convert from.

Returns:

arcsec_per_second – The value, in arcseconds per second, which you converted to.

Return type:

float

opihiexarata.library.conversion.degrees_to_sexagesimal_ra_dec(ra_deg: float, dec_deg: float, precision: int = 2) tuple[str, str][source]

Convert RA and DEC degree measurements to the more familiar HMSDMS sexagesimal format.

Parameters:
  • ra_deg (float) – The right ascension in degrees.

  • dec_deg (float) – The declination in degrees.

  • precision (int) – The precision of the conversion’s seconds term, i.e. how many numbers are used.

Returns:

  • ra_sex (str) – The right ascension in hour:minute:second sexagesimal.

  • dec_sex (str) – The declination in degree:minute:second sexagesimal.

opihiexarata.library.conversion.filter_header_string_to_filter_name(header_string: str) str[source]

The filter position string is exactly how it exists in the header files. This converts from the string as it exists in the header file to the filter name. The filter position set: {0: b, 1: 2, 2: 1, 3: z, 4: i, 5: r, 6: g, 7: c}

Parameters:

header_string (str) – The string as recorded in the header file which describes the filter position.

Returns:

filter_name – The name of the filter that corresponds to the given filter position.

Return type:

str

opihiexarata.library.conversion.full_date_to_julian_day(year: int, month: int, day: int, hour: int, minute: int, second: float) float[source]

A function to convert the a whole date format into the Julian day time.

Parameters:
  • year (int) – The year of the time stamp to be converted.

  • month (int) – The month of the time stamp to be converted.

  • day (int) – The day of the time stamp to be converted.

  • hour (int) – The hour of the time stamp to be converted.

  • minute (int) – The minute of the time stamp to be converted.

  • second (float) – The second of the time stamp to be converted.

Returns:

julian_day – The time input converted into the Julian day.

Return type:

float

opihiexarata.library.conversion.julian_day_to_decimal_day(jd: float) tuple[source]

A function to convert the Julian day time to the decimal day time.

Parameters:

jd (float) – The Julian day time that is going to be converted.

Returns:

  • year (int) – The year of the Julian day time.

  • month (int) – The month of the Julian day time.

  • day (float) – The day of the the Julian day time, the hours, minute, and seconds are all contained as a decimal.

opihiexarata.library.conversion.julian_day_to_full_date(jd: float) tuple[int, int, int, int, int, float][source]

A function to convert the Julian day to a full date time.

Parameters:

jd (float) – The Julian day time that is going to be converted.

Returns:

  • year (int) – The year of the Julian day provided.

  • month (int) – The month of the Julian day provided.

  • day (int) – The day of the Julian day provided.

  • hour (int) – The hour of the Julian day provided.

  • minute (int) – The minute of the Julian day provided.

  • second (float) – The second of the Julian day provided.

opihiexarata.library.conversion.julian_day_to_modified_julian_day(jd: float) float[source]

A function to convert Julian days to modified Julian days.

Parameters:

jd (float) – The Julian day to be converted to a modified Julian day.

Returns:

mjd – The modified Julian day value after conversion.

Return type:

float

opihiexarata.library.conversion.julian_day_to_unix_time(jd: float) float[source]

A function to convert between Julian days to UNIX time.

Parameters:

jd (float) – The Julian day to be converted.

Returns:

unix_time – The time converted to UNIX time.

Return type:

float

opihiexarata.library.conversion.modified_julian_day_to_julian_day(mjd: float) float[source]

A function to convert modified Julian days to Julian days.

Parameters:

mjd (float) – The modified Julian day to be converted to a Julian day.

Returns:

jd – The Julian day value after conversion.

Return type:

float

opihiexarata.library.conversion.numpy_type_string_to_instance(numpy_type_string: str) generic[source]

Provided an input string which is supposed to represent a Numpy type, this function provides the type instance itself.

The main reason for breaking this out into a new function is in the event that aliases needs to be made.

Parameters:

numpy_type_string (str) – The Numpy type, provided as a string which is formatted mostly as numpy.{type_string}. However, should alias exist, they will also be handled.

Returns:

numpy_type_instance – The data type instance that the string is likely referring to.

Return type:

Numpy generic

opihiexarata.library.conversion.sexagesimal_ra_dec_to_degrees(ra_sex: str, dec_sex: str) tuple[float, float][source]

Convert RA and DEC measurements from the more familiar HMSDMS sexagesimal format to degrees.

Parameters:
  • ra_sex (str) – The right ascension in hour:minute:second sexagesimal.

  • dec_sex (str) – The declination in degree:minute:second sexagesimal.

Returns:

  • ra_deg (float) – The right ascension in degrees.

  • dec_deg (float) – The declination in degrees.

opihiexarata.library.conversion.string_month_to_number(month_str: str) int[source]

A function to convert from the name of a month to the month number. This is just because it is easy to have here and to add a package import for something like this is silly.

Parameters:

month_str (string) – The month name. If it is exactly three characters in length, we assume it is abbreviated month names and search through that instead.

Returns:

month_int – The month number integer.

Return type:

int

opihiexarata.library.conversion.unix_time_to_julian_day(unix_time: float) float[source]

A function to convert between julian days to Unix time.

Parameters:

unix_time (float) – The UNIX time to be converted to a Julian day.

Returns:

jd – The Julian day value as converted.

Return type:

float