How to use the jdcal.jd2gcal function in jdcal

To help you get started, we’ve selected a few jdcal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CCI-Tools / cate / cate / core / opimpl.py View on Github external
if units:
        units = units.lower().strip()

    if long_name:
        units = long_name.lower().strip()

    units = units or long_name

    if not units or units != 'time in julian days':
        return ds

    ds = ds.copy()
    # Decode JD time
    # noinspection PyTypeChecker
    tuples = [jd2gcal(x, 0) for x in ds.time.values]
    # Replace JD time with datetime
    ds['time'] = [datetime(x[0], x[1], x[2]) for x in tuples]
    # Adjust attributes
    ds.time.attrs['long_name'] = 'time'
    ds.time.attrs['calendar'] = 'standard'

    return ds
github dcs4cop / xcube / xcube / core / normalize.py View on Github external
if units:
        units = units.lower().strip()

    if long_name:
        units = long_name.lower().strip()

    units = units or long_name

    if not units or units != 'time in julian days':
        return ds

    ds = ds.copy()
    # Decode JD time
    # noinspection PyTypeChecker
    tuples = [jd2gcal(x, 0) for x in ds.time.values]
    # Replace JD time with datetime
    ds['time'] = [datetime(x[0], x[1], x[2]) for x in tuples]
    # Adjust attributes
    ds.time.attrs['long_name'] = 'time'
    ds.time.attrs['calendar'] = 'standard'

    return ds
github oscaribv / pyaneti / phase.py View on Github external
ncol=3, mode="expand", borderaxespad=0.)
plt.subplot(212)
plt.xlabel( ' T (JD - %7f)'%sd_float )
plt.ylabel( 'phase' )
plt.ylim(0,1.1)
plt.plot(days,fase,'r-', label="Theoretical RV")
plt.plot(nightfa,fnightfa,'bo', label="night")
plt.savefig(fname + '.pdf')
plt.show()

#Let us make a nice print in the screen with hours and date

hdate = [None]*len(nightfa)

for i in range(0,len(hdate)):
	hdate[i] = jd.jd2gcal(sd_float,np.array(nightfa[i]))

dataf = open(fname+'.dat','w')	

dataf.write('#Object: %s\n'%objeto)
dataf.write('#Phases between %s and %s\n'%(idata[4],idata[5]))
dataf.write('# hour	phase\n')
dataf.write( '#------------------------#\n')
dataf.write('# %4i %2i %2i\n'%(hdate[0][0],hdate[0][1],hdate[0][2]))
dataf.write('#------------------------#\n')
for i in range(0,len(nightfa)):
	dataf.write('%2.2f	%1.4f\n'%(hdate[i][3]*24.0,fnightfa[i]))
	if (hdate[i][2] != hdate[i-1][2] and i > 1):
		dataf.write('#------------------------#\n')
		dataf.write(('# %4i %2i %2i\n'%(hdate[i][0],hdate[i][1],hdate[i][2])))
		dataf.write('#------------------------#\n')
github pwcazenave / PyFVCOM / PyFVCOM / utilities / time.py View on Github external
[2011,   11,   30,   23,   26,   15])

    """

    if not mjd:
        # It's easier to use jdcal in Modified Julian Day
        julianDay -= 2400000.5

    try:
        nt = len(julianDay)
    except TypeError:
        nt = 1

    greg = np.empty((nt, 6))
    if nt == 1:
        ymdf = jdcal.jd2gcal(2400000.5, julianDay)
        fractionalday = ymdf[-1]
        hours = int(fractionalday * 24)
        minutes = int(((fractionalday * 24) - hours) * 60)
        seconds = ((((fractionalday * 24) - hours) * 60) - minutes) * 60
        greg = np.asarray((ymdf[0], ymdf[1], ymdf[2], hours, minutes, seconds))
    else:
        for ii, jj in enumerate(julianDay):
            ymdf = jdcal.jd2gcal(2400000.5, jj)
            greg[ii, :3] = ymdf[:3]
            fractionalday = ymdf[-1]
            hours = int(fractionalday * 24)
            minutes = int(((fractionalday * 24) - hours) * 60)
            seconds = ((((fractionalday * 24) - hours) * 60) - minutes) * 60
            greg[ii, 3:] = [hours, minutes, seconds]

    return greg
github sam210723 / COMS-1 / coms.py View on Github external
def parseImageObservationTimeHeader(self, printInfo=False):
        """
        Parses HRIT Image Observation Time header (type 131)
        :param printInfo: Print info after parsing.
        """

        if self.readbytes(0) == b'\x83':
            self.imageObservationTimeHeader['valid'] = True
            self.imageObservationTimeHeader['header_type'] = 131
            self.imageObservationTimeHeader['header_len'] = int.from_bytes(self.readbytes(1, 2), byteorder='big')
            self.imageObservationTimeHeader['header_offset'] = self.byteOffset
            self.imageObservationTimeHeader['mjd'] = self.readbytes(3, self.imageObservationTimeHeader['header_len']-3).decode()
            self.imageObservationTimeHeader['date'] = jd2gcal(2400000.5, float(self.imageObservationTimeHeader['mjd']))

            self.byteOffset += self.imageObservationTimeHeader['header_len']
            if printInfo:
                self.printImageObservationTimeHeader()
        else:
            self.imageObservationTimeHeader['valid'] = False

jdcal

Julian dates from proleptic Gregorian and Julian calendars.

BSD-2-Clause
Latest version published 6 years ago

Package Health Score

67 / 100
Full package analysis

Similar packages