From 3be4ff154f8c53fbf0f90383c6317cedec6648cc Mon Sep 17 00:00:00 2001 From: rahulworld Date: Mon, 6 Aug 2018 00:10:45 +0530 Subject: [PATCH] adding downlaod file with conversion unit --- .../__pycache__/unitConvPint.cpython-36.pyc | Bin 2094 -> 1722 bytes .../__pycache__/observations.cpython-36.pyc | Bin 15225 -> 18638 bytes .../retrievers/aiopg/observations.py | 247 +++--------------- istsos/plugins/unit_con_pint/unitConvPint.py | 74 +++--- 4 files changed, 68 insertions(+), 253 deletions(-) diff --git a/istsos/plugins/unit_con_pint/__pycache__/unitConvPint.cpython-36.pyc b/istsos/plugins/unit_con_pint/__pycache__/unitConvPint.cpython-36.pyc index 032af4f4b6850f9599e55e7848cda53532808d31..39fd36f6d26e13756481745e162776674785a3e3 100644 GIT binary patch delta 211 zcmZ1{u#1<|n3tF9l1O^=%8i_lS?ZY>7#LWA*cph66@Wwu5N0u^FxD`pFiA3GGBz`& zF!zFZEH(@&48aVVtbVsxQW8rNZ}H?O6{i-JC6;97=M`%*-r~+G&d-Z4&Mz%WPQArZ zlv-Q>6i?M;DgxPYizhv`B)%jyw;(661SH4>6fELa2a!B*f)}KcH8HIuwMY%fEM@}| j4600wER$K;!x%*-$FLhRN=)u!Ph^Q=3XGrph207O9KJMD delta 563 zcmYjMO^Xvj5UuX%?)glN9t^_@3WAWmt%3*H+jTA#9{mCS2I;G({TJ4-2p+1s-s@NOs(uc>jp9dxLGt_8%h#vh<3DVd0RYE1!7x8C zIU-38l41lowDdpB5C@2P4khfNWeaHe<+)=|;q6%~EOA1L9QH(pV{mi~GQu|)LmRrV zq%zu*H?)n~*ai;klDT-dCvD=AlDDbjrN9Ak4lb3+SGp$zK0JN}Hnd?GIgZ9DE|v8^ za`2fT9v*{)7cjZ;%(K$em1nZBg^%CsdOh1zOY1{hUl&>Z&M3Vt?6R)R6~RM2IrMaA zYu$qh^%3?eyId>Jx5a9se0ZS>skE6;Jwl1jdmZsU zfw9_i)2z^)KA-8^*fovU#RAvaNaaP*G^&!CBJZ>Fg|aiN*3AmdCz(!qqqI*q`*f=p zF|Foinx53vR%v_MpA{fA74wUtS}1hXb00`!r{Oho^sji>Rs7)oJsbjbL`EVbj3n%i l7?L3q0V9G81x1c_U-%h$&|UE(a@ZY+g6q53(|r<8{sO1kmH7Yw diff --git a/istsos/plugins/unit_con_pint/retrievers/aiopg/__pycache__/observations.cpython-36.pyc b/istsos/plugins/unit_con_pint/retrievers/aiopg/__pycache__/observations.cpython-36.pyc index f916315779bb6af7a938934525a1ae7c3b4ec5d2..54db3b826f637a346e09bd078486685b63a80308 100644 GIT binary patch delta 7676 zcmb`L3z!^LmB*{9tE+puXC^a~$vpDxyfeYckZF>TAtI9p2_b{oWJuh0VeIKs{h03R z?y0UxGHs8gj06P5#704gx`2X$1jzU{fFg>bMtq@`u!^kiF1zmP?)usX?*H8C$0P>) z{Jzb6=XcM&_ncd|&b{~CO8?=|nd9<`a8pxY?YhJpUw*SBy(rE4_Ym~UAcg1D<16}Y znoI38FQHNgby8QtL)|o=7NA^6i)b+|K~IR5CKOsm%fS`2l2)O2bwZ{!)I)2bUjY3z zkY30->VwsV(AGoxDU8}h&^ACeLN-AzhHQomKNKeq05~@v4(wFHg^c1?j zN?)U=>FdzGLEoe^^et%5xPQ>Tjp4sT--Yw{==7UU068&?+R_I^om#F+Jn*R;*t4jH6l>ZL-56FK) zegpX}r&4P0TTLfDL+XUwdwhPV^>=5h}>=Nu2oG-XQ&|WBtMS_b3mk5RgmkKTuTrRjm zaHZfXK^#TA@fyJ%!L@=omT1Sp1aUOMb%K3@IHG7-Z;PT|Ff54EiVi-n_oLjHP(Yko z@Zu9EBNEEZkb#UG;Wk%SB5dXAo`|QSUy@M_HKNK@pDh`$p+&S>{k0jNG2oB*YYmrX z8jL_BU<4yUS=z~NuY+9ncGfP_wP{a8gEp{VS~Dn1((%(z+Y=sSvL_zi=g9jazJ1Yb zI+fKYRJSc!QMT(51>)PTXHtcX?kI-g1dLQBlQMKmH;X}`_lk<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?8jA9UVd?3By2T{Tmxa z&D_Xwp1Zek;VQBA(*NqiePLkp@EAjO>+9natrBTEi=^pdHfCoIrrx&|Y16$=cW(-X zIpbuN?9)3}njYp79_EgdvaL;`r0Er&vb|0CKZ`^-g?Ewcegotl)W5UW^a&sH#);`D zt6K_xyKdG^p)#`N<{yB>7bim9a`F#=+j5ni!1BjQn^L(HeBwCA#{zNEvKcYx2f>&nt|RJv<4t#11v?;>y$%G73q}&IxWG`s7sRO+ssrOB(H+-Py z1lh%YtsT~HAh)SjEVr8g?TMMFwy3e87U74M>#4|=AekcXFw8x$hVa> zh~5=ajgDUHtg}?xXh6;G+RKJs+lx#Z zv(uBt^uhu%mzI#WUKx4c$*vD**4d#sde-{g z=!|m5V|}=k=nRa$M8E84n1#6~_#d?##d44GC(GM z^6v1i=(Qb8TYpKwZ>j_sj>Vj|Ln8s?e~+Xhfkwe?Y27dTqBIq0g6 z<)$^ZI@$7~B{D-jNMV}tClMkDn*d!0YgD%lzKD!3Av}%n48l_ghZ%f&6#IKolntcp zO&?@y3z|^b=55q+Rjrq>n7>_b&zU*dn_dG>)>+6I=8bx#mxd=(7!7$1;U>bvlGM|S zI)fVaHwAL^$Dl|$Yil9e8o@b(2vLLqgc!on!I2bpl-vb?8U}jE<+Uq;*+7fT!_y+y z0mr3A#+P+gbbYG5gMdH8&neb`{X}p{|`6t$*BMU diff --git a/istsos/plugins/unit_con_pint/retrievers/aiopg/observations.py b/istsos/plugins/unit_con_pint/retrievers/aiopg/observations.py index 435ce6a..11ff5da 100644 --- a/istsos/plugins/unit_con_pint/retrievers/aiopg/observations.py +++ b/istsos/plugins/unit_con_pint/retrievers/aiopg/observations.py @@ -444,16 +444,12 @@ def __get_array_2(self, offerings, request): @asyncio.coroutine def __get_array(self, offerings, request): - # print("To PRINT REQUEST AT OBSERVATION") - # print(request[0]['offerings']['observable_properties']) - # To_unit=request['json']['in_unit'] - # print("################################3") ConvertUnit='' dbmanager = yield from self.init_connection() cur = dbmanager.cur op_filter = request.get_filter('observedProperties') - # print('Print Unit of observations line 250') - # print(op_filter) + print('Print Unit of observations line 250') + print(op_filter) tables = {} columns = [] headers = [{ @@ -514,22 +510,6 @@ def __get_array(self, offerings, request): unionSelect = [] jsonKeys = [] unionColumns = [] - # for idx in range(0, len(columns)): - # unionSelect.append( - # "SUM(c%s)::text as c%s" % (idx, idx) - # ) - # unionColumns.append( - # "NULL::double precision" - # ) - # jsonKeys.append("COALESCE(c%s, 'null')" % (idx)) - # for idx in range(0, len(columns)): - # unionSelect.append( - # "SUM(c%s)::text as c%s" % (idx, idx) - # ) - # unionColumns.append( - # "NULL::double precision as c%s" % (idx) - # ) - # jsonKeys.append("COALESCE(c%s, 'null')" % (idx)) for idx in range(0, len(columns)): unionSelect.append( @@ -545,30 +525,6 @@ def __get_array(self, offerings, request): temporal = [] where = [] params = [] - if request.get_filters() is not None: - keys = list(request.get_filters()) - for key in keys: - fltr = request.get_filters()[key] - if key == 'temporal': - if fltr['fes'] == 'during': - temporal.append(""" - begin_time >= %s::timestamp with time zone - AND - end_time <= %s::timestamp with time zone - """) - params.extend(fltr['period']) - - elif fltr['fes'] == 'equals': - temporal.append(""" - begin_time = end_time - AND - begin_time = %s::timestamp with time zone - """) - params.append(fltr['instant']) - - where.append( - "(%s)" % (' OR '.join(temporal)) - ) # print('Print Unit of Measurement') # print(headers) @@ -576,86 +532,17 @@ def __get_array(self, offerings, request): for table in tables.keys(): off_cols = tables[table] cols = unionColumns.copy() - # print('Print col in observations') - # print(cols) - # print(off_cols) for col in off_cols: - # ConvertScript="""np.ting from(select SUBSTRING(CAST(tmp.num as varchar),'[0-9]+') as ting from(select %s *'m'::unit@ 'mm' as num)as tmp)as np"""% (", ",col) - # ConvertScript=""" - # c0.ting as c0 - # from - # ( - # select SUBSTRING(CAST(tmp.num as varchar),'[0-9]+') as ting - # from - # ( - # select """+col+ """*'m'::unit@ 'mm' as num from data._belin - # )as tmp)""" - ################################## - # ConvertScript="""np.ting as c0 - # from - # ( - # select SUBSTRING(CAST(tmp.num as varchar),'[0-9]+') as ting - # from - # ( - # select """+col+ """*'m'::unit@ 'mm' as num - # )as tmp) as np""" - # # ConvertScript="np.ting from(select SUBSTRING(CAST(tmp.num as varchar),'[0-9]+') as ting from(select" +col+ "*'m'::unit@ 'mm' as num)as tmp)as np" - # print('Printing ConvertScript') - # print(ConvertScript) - ################################### - # cols[ - # columns.index(col) - # ] = unionColumns[columns.index(col)].replace( - # "NULL::double precision", ConvertScript - # ) - ####################################3 - # convert_unit="""%s*'%s'::unit@@'%s' """%(col,ConvertUnit,To_unit) - # print('Print convert query for postgresql-unit') - # print(convert_unit) - # cols[ - # columns.index(col) - # ] = unionColumns[columns.index(col)].replace( - # "NULL::double precision", - # convert_unit - # ) - ############################# - # cols[ - # columns.index(col) - # ] = unionColumns[columns.index(col)].replace( - # "NULL::double precision", - # col+"*'m'::unit@@'mm' " - # ) - if 'in_unit' in request['json']: - To_unit=request['json']['in_unit'] - convert_unit="""%s*'%s'::unit@@'%s' """%(col,ConvertUnit,To_unit) - # print('Print convert query for postgresql-unit') - # print(convert_unit) - cols[ - columns.index(col) - ] = unionColumns[columns.index(col)].replace( - "NULL::double precision", - convert_unit - ) - else: - cols[ - columns.index(col) - ] = unionColumns[columns.index(col)].replace( - "NULL::double precision", - col - ) - - # print('Print col in observations 1') - # print(cols) - # print(off_cols) - # uSql = """ - # SELECT - # end_time, %s - # FROM - # data.%s - # """ % ( - # ", ".join(cols), table - # ) + cols[ + columns.index(col) + ] = unionColumns[columns.index(col)].replace( + "NULL::double precision", + col + ) + print('Print col in observations 1') + print(cols) + print(off_cols) uSql = """ SELECT end_time, %s @@ -664,104 +551,25 @@ def __get_array(self, offerings, request): """ % ( ", ".join(cols), table ) + print('hhhhhhhhhhhhhhhhhhhhhhhhhhhh') - # print('Query Printing uSql') - # print(uSql) # uSql = """ # SELECT - # end_time, %s '*' %s ::unit@ %s + # end_time, %s # FROM # data.%s # """ % ( - # ", ".join(cols), ConvertUnit, To_unit, table + # ", ".join(cols), table # ) - if len(where) > 0: - uSql += "WHERE %s" % ( - 'AND'.join(where) - ) - unions.append("(%s)" % uSql) # print('Query Printing uSql') - # print(uSql) - - jsonSql = """ - SELECT array_agg( - ARRAY[ - to_char(end_time, 'YYYY-MM-DD"T"HH24:MI:SSZ'), - %s - ] - ) - FROM - """ % ( - ", ".join(jsonKeys), - ) - # print('Query Printing jsonSql') - # print(jsonSql) - # print('Query Printing unionSelect') - # print(unionSelect) - # print('union') - # print(unions) - - # sql = """ - # SET enable_seqscan=false; - # SET SESSION TIME ZONE '+00:00'; - # %s - # ( - # SELECT end_time, %s - # FROM ( - # %s - # ) a - # GROUP BY end_time - # ORDER BY end_time - # ) b - # """ % ( - # jsonSql, - # unionSelect, - # " UNION ".join(unions) - # ) - - sql = """ - SET enable_seqscan=false; - SET SESSION TIME ZONE '+00:00'; - %s - ( - SELECT end_time, %s - FROM ( - %s - ) a - GROUP BY end_time - ORDER BY end_time - ) b - """ % ( - jsonSql, - unionSelect, - " UNION ".join(unions) - ) + print(uSql) - # sql = """ - # SET enable_seqscan=false; - # SET SESSION TIME ZONE '+00:00'; - # %s + print('hhhhhhhhhhhhhhhhhhhhhhhhhhhhertrbbbbbbbbbbbbbbbet') + # istsos.debug( # ( - # SELECT end_time, %s*%s::unit@%s - # FROM ( - # %s - # ) a - # GROUP BY end_time - # ORDER BY end_time - # ) b - # """ % ( - # jsonSql, - # unionSelect, - # ConvertUnit, - # To_unit, - # " UNION ".join(unions) - # ) - - istsos.debug( - ( - yield from cur.mogrify(sql, tuple(params*len(unions))) - ).decode("utf-8") - ) + # yield from cur.mogrify(uSql, tuple(params*len(unions))) + # ).decode("utf-8") + # ) # istsos.debug( # ( # yield from cur.mogrify(sql, tuple(params*2)) @@ -770,11 +578,18 @@ def __get_array(self, offerings, request): # print("Observation.py") # print(sql) - yield from cur.execute(sql, tuple(params*len(unions))) - # yield from cur.execute(sql, tuple(params*0)) + sql="SELECT _9 as c0 FROM data._belin" + yield from cur.execute(sql, { "type": "array" }) + print('hhhhhhhhhhhhhhhhhhhhhhhhhhhhertredsfsdfggggggggggggggggggggggt') rec = yield from cur.fetchone() - request['observations'] = rec[0] - request['headers'] = headers + print('rec1') + print(rec) + request['observations'] = [] + # request['headers'] = headers + # dbmanager1 = yield from self.init_connection() + # cur1 = dbmanager1.cur + # yield from cur1.execute(uSql) + # rec1 = yield from cur1.fetchone() # recs = yield from cur.fetchall() istsos.debug("Data is fetched!") diff --git a/istsos/plugins/unit_con_pint/unitConvPint.py b/istsos/plugins/unit_con_pint/unitConvPint.py index 96cd797..353a51a 100644 --- a/istsos/plugins/unit_con_pint/unitConvPint.py +++ b/istsos/plugins/unit_con_pint/unitConvPint.py @@ -37,44 +37,44 @@ def before(self, request): @asyncio.coroutine def after(self, request): - from_unit=request['json']['data']['from_unit'] - to_unit=request['json']['data']['to_unit'] - # time=request['json']['headers'][0]['column'] - # value=request['json']['headers'][1]['name'] - # from_unit=request['headers'][1]['uom'] - # to_unit=request['json']['to'] - # print(request['observations']) - recs=request['observations'].copy() - ConvertUnit=[] - for rec in recs: - # change=rec[1]*ureg.kilometers - # change1=change.to(ureg.meter) - # change2=change1.magnitude - change=str(rec[1])+"*"+from_unit+"to"+to_unit - # change=Q_(str(rec[1]), ureg.degC).to(ureg.kelvin) - # change=str(rec[1])+"*degC"+"to"+"degF" - # change=str(rec[1])+"*ureg.degC"+"to"+"ureg.degF" - # change=rec[1]*ureg.degC - # change=str(rec[1])+"* kelvin to degF" - src, dst = change.split('to') - change1=Q_(src).to(dst) - # home = Q_(rec[1], ureg.degC) - # change1=home.to('degF') - # change1=Q_(rec[1], ureg.degC).to(ureg.kelvin).magnitude - change2=change1.magnitude - # print(change2) - # print(change1) - ConvertUnit.append({ - "datetime" : rec[0], - "value": change2 - }) - # request['observations1'].append({ - # "timestamp": str(rec[0]), - # "rainfall": change2 - # }) + # from_unit=request['json']['data']['from_unit'] + # to_unit=request['json']['data']['to_unit'] + # # time=request['json']['headers'][0]['column'] + # # value=request['json']['headers'][1]['name'] + # # from_unit=request['headers'][1]['uom'] + # # to_unit=request['json']['to'] + # # print(request['observations']) + # recs=request['observations'].copy() + # ConvertUnit=[] + # for rec in recs: + # # change=rec[1]*ureg.kilometers + # # change1=change.to(ureg.meter) + # # change2=change1.magnitude + # change=str(rec[1])+"*"+from_unit+"to"+to_unit + # # change=Q_(str(rec[1]), ureg.degC).to(ureg.kelvin) + # # change=str(rec[1])+"*degC"+"to"+"degF" + # # change=str(rec[1])+"*ureg.degC"+"to"+"ureg.degF" + # # change=rec[1]*ureg.degC + # # change=str(rec[1])+"* kelvin to degF" + # src, dst = change.split('to') + # change1=Q_(src).to(dst) + # # home = Q_(rec[1], ureg.degC) + # # change1=home.to('degF') + # # change1=Q_(rec[1], ureg.degC).to(ureg.kelvin).magnitude + # change2=change1.magnitude + # # print(change2) + # # print(change1) + # ConvertUnit.append({ + # "datetime" : rec[0], + # "value": change2 + # }) + # # request['observations1'].append({ + # # "timestamp": str(rec[0]), + # # "rainfall": change2 + # # }) request['response'] = Response( json_source=Response.get_template({ - "data": ConvertUnit, - "headers": request['headers'] + "data": request['observations'], + # "headers": request['headers'] }) ) \ No newline at end of file