本文整理汇总了Python中mx.DateTime.gmt方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.gmt方法的具体用法?Python DateTime.gmt怎么用?Python DateTime.gmt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mx.DateTime
的用法示例。
在下文中一共展示了DateTime.gmt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GetValue
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import gmt [as 别名]
def GetValue(self, manager, value, value_type = None):
retval = None
if manager == "ScanCoordinator":
if value == "receiver":
retval = "Rcvr1_2"
elif value == "nextScanNumber":
retval = "2"
elif value == "startTime,MJD":
gmt = DateTime.gmt()
loci = Loci()
mjd, _ = loci.DateTime2TimeStamp(gmt)
retval = str(mjd)
elif value == "startTime,seconds":
gmt = DateTime.gmt()
loci = Loci()
_, secs = loci.DateTime2TimeStamp(gmt)
retval = str(secs)
elif value == "projectId":
retval = 'TAPI_FRANK'
elif manager == "DCR":
if value.find("Channel,") == 0 or value.find("CH1_16,Tsys") == 0:
retval = "1"
elif manager == "Antenna":
if value == "azWrapMode":
retval = 'Auto'
elif manager == "Antenna,AntennaManager":
if value == "ccuData,Az,indicated":
retval = "180.0"
if retval is None:
retval = "%s's value" % value
self.Comment("GetValue(%s, %s) returning %s\n" % (manager,
value,
retval))
return retval
示例2: most_recent
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import gmt [as 别名]
def most_recent(self, user, filter=None):
" Return DateTime of most recent picture, or today "
try:
if filter is None: # unfiltered if no filter
filter = True
pic = db.Picture.select(
self.collection.db_filter(user) & filter, orderBy=db.Picture.q.record_time
).reversed()[0]
return to_mxDateTime(pic.record_time)
except IndexError:
return mxdt.gmt()
示例3: riseSetLSTs
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import gmt [as 别名]
def riseSetLSTs(self, raDegress, decDegrees, now = None):
"""
For a source at apparent location (ApparentRaDec), and for a
horizon corrected for refraction (all in degrees), returns
the next rise and set times in LST as a DateTimeDelta objects.
For northern circumpolar objects rise is current time and set
is None; for southern circumpolar objects rise is None and set
is current time.
"""
h = raDegress
v = decDegrees
if now is None:
now = DateTime.gmt()
ra = self.getRightAscension(h)
dec = v
gblst = TimeAgent.Absolute2RelativeLST(now)
current_ha = gblst - ra
# HA must be between -12 and +12 hours.
if current_ha < -12:
current_ha = current_ha + 24.0
elif current_ha > 12:
current_ha = current_ha - 24.0
horizon_ha = self.hourAngleIntersection(dec)
# Does the source set?
if horizon_ha >= 12.0:
return (gblst, None)
# Does the source rise?
elif horizon_ha <= 0:
return (None, gblst)
# So when?
else:
# Rise LST is when the HA = -horizon_ha
# Set LST is when HA = +horizon_ha
lstrise = ra - horizon_ha
lstset = ra + horizon_ha
# Keep it in the future.
if lstrise < 0:
lstrise += 24
if lstset < 0:
lstset += 24
return (DateTime.DateTimeDelta(0, lstrise, 0, 0),
DateTime.DateTimeDelta(0, lstset, 0, 0))
示例4: RelativeLST2AbsoluteTime
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import gmt [as 别名]
def RelativeLST2AbsoluteTime(lst, now = None):
"""
Returns today's DateTime in UTC, defined as first corresponding
time after now, from given LST in hours.
"""
lst = DateTime.DateTimeDelta(0, lst, 0, 0)
if now is None:
now = DateTime.gmt()
else:
now = dt2mxDT(now)
# Now's mjd at 0h
mjd0 = int(now.mjd)
# Convert requested LST to degrees
requested_lst = 15*lst.hours
# Local LMST for 0h UT in degrees
lst0 = (180.0/math.pi)*slalib.sla_gmst(mjd0) + GBTLONG
# LST difference between 0h UT and requested LST
lst_offset = requested_lst - lst0
solar_sidereal_ratio = (365.25/366.25)
# options for solar time at 1 day sidereal intervals
options = []
for cycle in range(720, -1080, -360):
solar_time = ((lst_offset-cycle)/15.0)*solar_sidereal_ratio
mjd = mjd0 + solar_time/24
options.append(DateTime.DateTimeFromMJD(mjd))
# Select the time following the target time
target = DateTime.DateTimeFromMJD(now.mjd)
for option in options:
if target < option:
return mxDT2dt(option)
return mxDT2dt(option[-1])
示例5: run_query
# 需要导入模块: from mx import DateTime [as 别名]
# 或者: from mx.DateTime import gmt [as 别名]
def run_query():
cur_buy.execute(
"SELECT bid,current_market.systemid,current_market.stationid,price,volremain,(issued+duration),range,regionname, (reportedtime),stationname,security,minvolume,regions.regionid,orderid FROM current_market,regions,stations,systems WHERE "
+ reg_block
+ " AND stations.systemid = systems.systemid AND typeid = %s AND stations.stationid = current_market.stationid AND current_market.regionid = regions.regionid AND now() - reportedtime <= '"
+ sql_age
+ "' AND volremain >= %s AND current_market.bid = 1 "
+ sql_system
+ " ORDER BY "
+ order
+ " "
+ borderdir
+ " "
+ limit,
[typeid, minQ],
)
cur_sell.execute(
"SELECT bid,current_market.systemid,current_market.stationid,price,volremain,(issued+duration),range,regionname,(reportedtime),stationname,security,regions.regionid,orderid FROM current_market,regions,stations,systems WHERE "
+ reg_block
+ " AND typeid = %s AND stations.systemid = systems.systemid AND stations.stationid = current_market.stationid AND current_market.regionid = regions.regionid AND now() - reportedtime <= '"
+ sql_age
+ "' AND volremain >= %s AND current_market.bid = 0 "
+ sql_system
+ " ORDER BY "
+ order
+ " "
+ orderdir
+ " "
+ limit,
[typeid, minQ],
)
for (query, lista, isbuy) in [(cur_buy, buys, True), (cur_sell, sells, False)]:
r = query.fetchone()
while r:
rec = {}
rec["systemid"] = r[1]
rec["stationid"] = r[2]
price = float(r[3])
string = format_price(price)
rec["price"] = string
rec["price_raw"] = price
rec["volremain"] = format_long(r[4])
rec["volremain_raw"] = r[4]
rec["expires"] = str(r[5])[0:10]
if r[0] == True:
rec["range"] = r[6]
else:
rec["range"] = -2
rec["regionname"] = r[7]
reported = DateTime.DateTimeFrom(str(r[8]))
now = DateTime.gmt()
hours = (now - reported).hours
if hours >= 1:
rec["reportedtime"] = "%d hours ago" % (hours)
else:
rec["reportedtime"] = "%d minutes ago" % (now - reported).minutes
rec["stationname"] = r[9]
sec = r[10]
ssec = str(sec)[0:3]
if sec <= 0.0:
ssec = "0.0"
rec["security"] = ssec
# Try to grab regionid from the end of the query
if isbuy:
if int(r[11]) > 1:
rec["minvolume"] = format_long(r[11])
rec["minvolume_raw"] = int(r[11])
else:
rec["minvolume"] = 1
rec["minvolume_raw"] = 1
rec["regionid"] = r[12]
rec["orderid"] = r[13]
else:
rec["minvolume"] = 1
rec["minvolume_raw"] = 1
rec["regionid"] = r[11]
rec["orderid"] = r[12]
lista.append(rec)
r = query.fetchone()