def last_update_was_ago(self, **kwargs): """Arguments can be: days[, seconds[, microseconds[, milliseconds[, minutes[, hours[, weeks]""" return self.last_update + datetime.deltatime(**kwargs) < datetime.datetime.now()
def fetch_past_data_status(start_day, end_day, status): today = datetime.datetime.now() range_a = today - datetime.deltatime(days = start_day) range_b = today - datetime.deltatime(days = end_day) date_range = "&created_at_min=2021-03-{}&created_at_max=2021-03-{}".format(str(range_b).split()[0], str(range_a).split()[0])
from sqlalchemy import Table from sqlalchemy.ext.compiler import compiles from sqlalchemy.sql.expression import Executable, ClauseElement class CreateView(Executable, ClauseElement): def __init__(self, name, select): self.name = name self.select = select @compiles(CreateView) def visit_create_view(element, compiler, **kw): return "CREATE VIEW %s AS %s" % ( element.name, compiler.process(element.select, literal_binds=True) ) # create view from app.models import Topic from datetime import datetime, deltatime from app import db engine = db.engine createview = CreateView('active_topics', Topic.query.filter_by(last_modified > )(datetime.utcnow() - deltatime(days=30))) engine.execute(createview) # reflect view and print result v = Table('viewname', metadata, autoload=True) for r in engine.execute(v.select()): print r
def main(): dT = 70 # Kelvin utc = '2007-Jan-28-28T21:12:55' # time of PSP_002380_0985 = 174.477 # angles between normal to the disk surface and Z-axis disk1 = DustParticle(normal = array((0,0,1)), time = utc) # rotating a z-normal by 10 degree around (0,1,0) # axis count starts at 0 ! # disk2 = DustParticle(normal = array((0,0,1)), degree=10, axis = 1) time_step = dt.deltatime(hours=1) # coordinates of secondary halos in Inca City: lon = 296.591709, lat = -81.512266 # set surface point via these coordinates disk1.set_spoint_by(lon=-81.512266, lat= 296.591709) # writing into a string and saving to file later output = cStringIO.StringIO() x = 0 x2 = 0 ds = 0 while mspicer.l_s < 250: # if sun's lowest point is under horizon, there was time for freezing if hn < 0: Tch = 0 # here solar incidence measured in height over horizon h = 90 - mspicer.coords.dsolar # if sun's under the horizon if h < 0: write_output(output, (mspicer.l_s, x, x2, hv, hn, h, disk1.mu, disk1.I, ds)) disk1.time += time_step continue # sun is over horizon sun_vec = mspicer.sun_direction # length of passage of light through ice ds = cos(pi/2. - h)*(x + r)*1000000; # put' sveta vo ldu v micronah # exponential attenuation in this length #E = E*exp(-4.*pi*0.0001*ds/35);# s pogloscheniem #discs Ed1 = disk1.P #Ed = Ed*exp(-4.*pi*0.0001*ds/35.);# s pogloscheniem md = Ed1 / (CO2.s * dT + CO2.L) # mass / t [g/s] Vd = md/CO2.rho # Vol / t [m**3/s] mchd = rho*pi*r*r*r/10. # why would this be the mass of the disk? Ed2 = disk2.P #Ed2 = Ed2*exp(-4.*pi*0.0001*ds/35.);# s pogloscheniem md2 = Ed2 / (CO2.s * dT + CO2.L); Vd2 = md2/CO2.rho #nagrevanie chastichki # warming up of the particle # 217: equilibrium T of CO2 if (Tch < 217): # duration of warming up tnagd = floor((disk1.S * disk1.r / 10.) * disk1.sreg * dT / Ed1) + 1 Tch = 217 else: tnagd = 0
def get_time(self): return datetime.deltatime(self.seconds)