From 33096138710c290488d8588c71f9ff3cd541ded3 Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Mon, 14 Oct 2019 09:21:21 +0200 Subject: [PATCH] add sequence function seq --- docs/build/html/_modules/data.html | 34 ++++++++++++++-- docs/build/html/_modules/geometry.html | 34 +++++++++++++++- docs/build/html/_modules/geometry_plot.html | 8 ++-- docs/build/html/data.html | 33 ++++++++++++++- docs/build/html/genindex.html | 12 +++++- docs/build/html/geometry.html | 42 +++++++++++++++++++- docs/build/html/objects.inv | Bin 780 -> 794 bytes docs/build/html/py-modindex.html | 2 +- docs/build/html/searchindex.js | 2 +- src/data.py | 40 +++++++++++++++++-- 10 files changed, 189 insertions(+), 18 deletions(-) diff --git a/docs/build/html/_modules/data.html b/docs/build/html/_modules/data.html index f3d0489..8e9130b 100644 --- a/docs/build/html/_modules/data.html +++ b/docs/build/html/_modules/data.html @@ -35,13 +35,13 @@

Source code for data

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
-"""Read and write data to or from file.
+"""Read and write data to or from file and manipulate data structures.
 
-:Date: 2019-07-29
+:Date: 2019-10-11
 
 .. module:: data
   :platform: *nix, Windows
-  :synopsis: Handle data files.
+  :synopsis: Handle data files and structures.
 
 .. moduleauthor:: Daniel Weschke <daniel.weschke@directbox.de>
 """
@@ -155,6 +155,34 @@
     length = int(k/n)
     return [lst[i*n:i*n+n] for i in range(length)]
+
[docs]def seq(start, stop=None, step=1): + r"""Create an arithmetic bounded sequence. + + The sequence is one of the following; + + - empty :math:`\{\}=\emptyset`, if start and stop are the same + - degenerate :math:`\{a\}`, if the sequence has only one element. + - left-close and right-open :math:`[a, b)` + + :param start: start of the sequence, the lower bound. If only start + is given than it is interpreted as stop and start will be 0. + :type start: int or float + :param stop: stop of sequence, the upper bound. + :type stop: int or float + :param step: step size, the common difference (constant difference + between consecutive terms). + :type step: int or float + :returns: arithmetic bounded sequence + :rtype: list + """ + if stop is None: + return seq(0, start, step) + n = int(math.ceil((stop - start)/float(step))) + lst = [] + if n > 0: + lst = [start + step*i for i in range(n)] + return lst
+
[docs]def unique_ending(ids, n=1): """From id list get list with unique ending. diff --git a/docs/build/html/_modules/geometry.html b/docs/build/html/_modules/geometry.html index 0e78238..8bfdf1f 100644 --- a/docs/build/html/_modules/geometry.html +++ b/docs/build/html/_modules/geometry.html @@ -37,7 +37,7 @@ # -*- coding: utf-8 -*- """2D geometry objects. -:Date: 2019-08-20 +:Date: 2019-08-28 .. module:: geometry :platform: *nix, Windows @@ -49,6 +49,36 @@ import numpy as np +
[docs]def distance(point1, point2): + """Distance between two points (or length of a straight line). + + :param point1: first point (first end point of straight line) + :type point1: tuple + :param point2: second point (second end point of straight line) + :type point2: tuple + + :returns: distance between the two points + :rtype: float + """ + return math.sqrt((point2[0]-point1[0])**2 + (point2[1]-point1[1])**2)
+ + +
[docs]def angle(point1, point2=None): + """Angle of point or between two points. + + :param point1: (first) point + :type point1: tuple + :param point2: second point (default = None) + :type point2: tuple + + :returns: angle of point or between two points + :rtype: float + """ + if point2 is None: + return math.atan2(point1[1], point1[0]) + return math.atan2(point2[1]-point1[1], point2[0]-point1[0])
+ +
[docs]def translate(vec, *pts): """Translate a point or polygon by a given vector. @@ -316,7 +346,7 @@ if 'global_deformation' in kwargs: lr = [(pts[l-kwargs['index_offset']], pts[r-kwargs['index_offset']]) for l, r in kwargs['inc']] - ang = [math.atan2(r[1]-l[1], r[0]-l[0]) for l, r in lr] + ang = [angle(l, r) for l, r in lr] # system deformation U = kwargs['global_deformation'] if 'rotation_plane' in kwargs and 'xz' == kwargs['rotation_plane']: diff --git a/docs/build/html/_modules/geometry_plot.html b/docs/build/html/_modules/geometry_plot.html index 2a0fc3d..5340452 100644 --- a/docs/build/html/_modules/geometry_plot.html +++ b/docs/build/html/_modules/geometry_plot.html @@ -47,7 +47,9 @@ """ import math import pylab -from geometry import line, interpolate_hermite, rotate_xy, translate_xy +from geometry import ( + distance, angle, line, interpolate_hermite, rotate_xy, translate_xy +) pylab.style.use('dark_background') pylab.rcParams['grid.color'] = 'gray' @@ -109,8 +111,8 @@ for ln in lns: l, r, d = ln - L = math.sqrt((r[0]-l[0])**2 + (r[1]-l[1])**2) - ang = math.atan2(r[1]-l[1], r[0]-l[0]) + L = distance(l, r) + ang = angle(l, r) x, y = interpolate_hermite(d[1], d[2], d[4], d[5], d[0], d[3], scale_x=L, scale_y=factor, samples=samples) x, y = rotate_xy((0, 0), ang, x, y) diff --git a/docs/build/html/data.html b/docs/build/html/data.html index 52cf77e..bbc4ef0 100644 --- a/docs/build/html/data.html +++ b/docs/build/html/data.html @@ -34,10 +34,10 @@

data module

-

Read and write data to or from file.

+

Read and write data to or from file and manipulate data structures.

Date
-

2019-07-29

+

2019-10-11

@@ -125,6 +125,35 @@ array. m = k / n

+
+
+seq(start, stop=None, step=1)[source]
+

Create an arithmetic bounded sequence.

+

The sequence is one of the following;

+
    +
  • empty \(\{\}=\emptyset\), if start and stop are the same

  • +
  • degenerate \(\{a\}\), if the sequence has only one element.

  • +
  • left-close and right-open \([a, b)\)

  • +
+
+
Parameters
+
    +
  • start (int or float) – start of the sequence, the lower bound. If only start +is given than it is interpreted as stop and start will be 0.

  • +
  • stop (int or float) – stop of sequence, the upper bound.

  • +
  • step (int or float) – step size, the common difference (constant difference +between consecutive terms).

  • +
+
+
Returns
+

arithmetic bounded sequence

+
+
Return type
+

list

+
+
+
+
store(file_name, object_data)[source]
diff --git a/docs/build/html/genindex.html b/docs/build/html/genindex.html index 76386de..9eff453 100644 --- a/docs/build/html/genindex.html +++ b/docs/build/html/genindex.html @@ -59,6 +59,10 @@

A

+ - +
@@ -284,6 +290,8 @@
    +
  • seq() (in module data) +
  • square() (in module geometry)
  • store() (in module data) diff --git a/docs/build/html/geometry.html b/docs/build/html/geometry.html index f75b78a..e8c2cd2 100644 --- a/docs/build/html/geometry.html +++ b/docs/build/html/geometry.html @@ -37,10 +37,30 @@

    2D geometry objects.

    Date
    -

    2019-08-20

    +

    2019-08-28

    +
    +angle(point1, point2=None)[source]
    +

    Angle of point or between two points.

    +
    +
    Parameters
    +
      +
    • point1 (tuple) – (first) point

    • +
    • point2 (tuple) – second point (default = None)

    • +
    +
    +
    Returns
    +

    angle of point or between two points

    +
    +
    Return type
    +

    float

    +
    +
    +
    + +
    cubic(point1, angle1, point2, angle2, samples=10)[source]

    Cubic line defined by two end points and the rotation in radians @@ -141,6 +161,26 @@ decides what the left and the right end point of the line is.

  • +
    +
    +distance(point1, point2)[source]
    +

    Distance between two points (or length of a straight line).

    +
    +
    Parameters
    +
      +
    • point1 (tuple) – first point (first end point of straight line)

    • +
    • point2 (tuple) – second point (second end point of straight line)

    • +
    +
    +
    Returns
    +

    distance between the two points

    +
    +
    Return type
    +

    float

    +
    +
    +
    +
    interpolate_hermite(lvd, lr, rvd, rr, lhd=0, rhd=0, scale_x=1, scale_y=1, samples=10)[source]
    diff --git a/docs/build/html/objects.inv b/docs/build/html/objects.inv index 4174bafa9dd0e16c32bd0d55bb0d5c3a509d08b8..105c25f985795bb8a4838e242e1933b174e67836 100644 GIT binary patch delta 690 zcmV;j0!{sl2AT$tbbpsUvfCgK$9tbbnWVKQFO%xsAVp>}^NN%VhLuE&Kn67LIaRKa zDu>BUa*`k+%Se`ORxWJI%m23v%h!riN3-VmTx;G+$UbJ=8}iE4@_jIEKV;iYZ!EOr zL<;LVebFlBgjU&8M2ylB91;A!PHLK80frNekg7c~or;MldQbl39YT!I|SkellKF=Twz)K9^H!B4_PRFr=Jt zD3ORw*K@x^sefXKF$kY{(`e}vO)4<;!Th35rC2Axig6SA(q;`v2q;I*pPeN<=MZ%iCHM5bcD?Si(w^~a>dr{g+Ft%Xz zdHQKHVY(yG&WAH&uRvr7nF>CTjhO8gPXj+Oku?W&M1RlZ@Pv$#!zVQH8A}w6z#;-Y z5CyL_HGATJomM{Ml?~JOuoGhV9_h$m{~Y9+DGX$H(X5NvlSI`I!F9@j)7L0AAx_lL z6=*|6G!l{h7L)tW{D8PXml&daIfVr)-5R?JS`|(xVtpm2I67u6RO?_ZwyLu$dpcmN zLiQJRk$(tw?-7}G{F!T(ZKL;!{wWK~E4*J!RWPdHq$)uP#o?`2O1kr_ecRo$!5Z{m zy2o?z9Qm9S5#ztJ@3^2?z|PnB)O2!i?%4oFo%#-vc_ee%r%a07zhA#?=4F0+D%W3N z?>64e!r+?Y_S6tueGNM`3^Rnban!*S#MZE=dMk)j(}N+4Dh$f@w1kZXYFIVxORxpv YCA5F*wDDOI#h5RL*l28;%fbbppRa@#NvhI^fYnWPmb_N4L+Qe-AGE>dD3U`ZmvgT`ZQrSdgW zy|Gf9 zBF>EM^p%suG9`<|KP@fPX+zChObsSIz8AuQ0D5 zEL9LnYzRo>ogh`ApJ1Fh_Y70dC17Jgqe?T156N<&WRBdpG;lfKL{H6%?Rda#jHUIu=+5OAB`8)C2>1OW+_amb2*|=XCfwD&wO2U ztGKTNYCwzgUVpm+b0#y@8JTGy7R#DvM9|7&o2}0)@W8ws(h>9Gu+B)!YAg-U+R2FI zB!*h9>|zJ^D;L{1tag7;=+J9VHga{rM+V(>YproFN_$bqm0W$9ei%%c?u0V)?abH< z5E??Jf_GFSX1nHT;a5&%MIk$)XG(a;j8ej5Ht{8wsDE0Pi?HmCNO%=k?~(tuO8Sa7 zCOo#goghv3nU4JJOo6X?gn=w6GwWjZB$DDTSfp$?y+?BkVwr$$ei{ark%;Wqn9_gd z2gDh=#31RXom{X{PMcNGs&Gsq;|DECvttS-orSg7s$^GYI$*0p_7`=P2zFzBVJv;3 ziWJ*u?0@fn6`{St_&-&_sDh)a2FWCaw_eHd&UgE^yJv$n=)ZP9PqS_0b23DX|DAlt z1H}S%y2hubqk~gs0~jUs132+WVU;f#XS;vzzfIv~{`Hi$zra3hyqks1wTJC-A-MV$ z-qf(o5Zc612U8FmO`_=`QcVwrBAPHT+2a~E1|6^_%`}%_3&e9+|K4fivm}Z!Z->}$ KEZTqlYHzA7bV data (*nix, Windows) - Handle data files. + Handle data files and structures. diff --git a/docs/build/html/searchindex.js b/docs/build/html/searchindex.js index bf1817e..3284548 100644 --- a/docs/build/html/searchindex.js +++ b/docs/build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["data","date","geometry","geometry_plot","index","modules","numerical","time_of_day"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["data.rst","date.rst","geometry.rst","geometry_plot.rst","index.rst","modules.rst","numerical.rst","time_of_day.rst"],objects:{"":{data:[0,0,0,"-"],date:[1,0,0,"-"],fit:[6,0,0,"-"],geometry:[2,0,0,"-"],geometry_plot:[3,0,0,"-"],integration:[6,0,0,"-"],numerical:[6,0,0,"-"],ode:[6,0,0,"-"],ode_model:[6,0,0,"-"],time_of_day:[7,0,0,"-"]},"numerical.fit":{gauss:[6,1,1,""],gauss_fit:[6,1,1,""]},"numerical.integration":{trapez:[6,1,1,""]},"numerical.ode":{e1:[6,1,1,""],e2:[6,1,1,""],e4:[6,1,1,""],fpi:[6,1,1,""],i1:[6,1,1,""],newmark_newtonraphson:[6,1,1,""],newmark_newtonraphson_rdk:[6,1,1,""]},"numerical.ode_model":{disk:[6,1,1,""],disk_nm:[6,1,1,""],disk_nmmdk:[6,1,1,""]},data:{fold_list:[0,1,1,""],get_id:[0,1,1,""],load:[0,1,1,""],read:[0,1,1,""],store:[0,1,1,""],unique_ending:[0,1,1,""],write:[0,1,1,""]},date:{"gau\u00dfsche_osterformel":[1,1,1,""],ascension_of_jesus:[1,1,1,""],easter_friday:[1,1,1,""],easter_monday:[1,1,1,""],easter_sunday:[1,1,1,""],pentecost:[1,1,1,""]},geometry:{cubic:[2,1,1,""],cubic_deg:[2,1,1,""],cubics:[2,1,1,""],interpolate_hermite:[2,1,1,""],line:[2,1,1,""],lines:[2,1,1,""],rectangle:[2,1,1,""],rotate:[2,1,1,""],rotate_deg:[2,1,1,""],rotate_xy:[2,1,1,""],square:[2,1,1,""],translate:[2,1,1,""],translate_xy:[2,1,1,""]},geometry_plot:{plot_cubic_lines:[3,1,1,""],plot_lines:[3,1,1,""]},numerical:{fit:[6,0,0,"-"],integration:[6,0,0,"-"],ode:[6,0,0,"-"],ode_model:[6,0,0,"-"]},time_of_day:{days:[7,1,1,""],days_norm:[7,1,1,""],hours:[7,1,1,""],hours_norm:[7,1,1,""],in_seconds:[7,1,1,""],minutes:[7,1,1,""],minutes_norm:[7,1,1,""],seconds:[7,1,1,""],seconds_norm:[7,1,1,""],transform:[7,1,1,""]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:function"},terms:{"1st":6,"2nd":6,"4th":6,"9fsche_osterformel":1,"case":6,"char":0,"default":[0,2,6,7],"f\u00fcr":1,"float":[2,6,7],"fr\u00fchling":1,"function":6,"gau\u00dfsch":1,"gau\u00dfsche_osterformel":1,"int":[0,1,2,6],"korrekturgr\u00f6\u00df":1,"m\u00e4rz":1,"m\u00e4rzdatum":1,"new":7,"return":[0,1,2,6,7],"s\u00e4kular":1,"s\u00e4kularzahl":1,"vorw\u00e4rt":6,Das:1,The:[2,6,7],absolut:2,addit:2,against:6,algorithmu:1,als:1,alwai:[],amplitud:6,analyt:6,angl:2,angle1:2,angle2:2,approx:6,approxim:6,april:1,area:6,argument:2,around:2,arrai:0,ascens:1,ascension_of_jesu:1,ascii:0,assum:2,assumend:[],averag:7,backward:6,base:6,becom:6,begin:6,beta:6,between:2,binari:0,bmatrix:6,bool:[0,6],bottom:2,boundari:2,build:2,calcul:[1,6,7],cauchi:6,cdot:6,center:2,chang:2,choos:6,column:0,composit:6,condit:[2,6],content:5,convert:[0,7],coordin:2,counterclockwis:2,cubic:2,cubic_deg:2,dai:[1,7],data:[5,6],date:[0,2,3,5,6,7],datetim:1,datum:1,days_norm:7,ddot:6,decid:2,defin:2,definit:6,deflect:2,deform:2,degre:2,den:1,der:1,derform:2,deriv:6,des:1,describ:6,deviat:6,diamet:6,die:1,differ:6,differenti:6,dimension:0,dimenson:0,direct:2,disk:6,disk_nm:6,disk_nmmdk:6,displac:[2,6],distribut:6,divid:6,doe:2,dot:6,each:2,easter:1,easter_fridai:1,easter_mondai:1,easter_sundai:1,eccentr:6,edg:2,either:2,element:2,end:[0,2,6],endpoint:2,entfernung:1,equal:6,equalii:6,equat:6,error:6,ersten:1,euler:6,everi:6,exampl:[2,6],expect:6,explicit:6,explizit:6,f_n:6,factor:2,fail:0,fals:[0,6],fassregel:6,file:0,file_nam:0,filenam:0,first:[0,6],fit:5,fix:6,float64:6,fnm:6,fold_list:0,foral:6,forward:6,fourth:6,fpi:6,frac:[2,6],fridai:1,from:[0,6],full:[0,6],fwhm:6,gamma:6,gau:1,gauss:6,gauss_fit:6,geometri:[3,5],geometry_plot:[2,5],get:0,get_id:0,gilt:1,given:[2,6],global:[2,6],global_deform:2,govern:6,gregorian:7,gregorianischen:1,half:6,has:6,height:2,hermit:2,horizont:2,hour:7,hours_norm:7,http:1,ids:0,implement:[],implicit:6,in_second:7,inc:2,incid:2,index:[0,2,4],index_offset:2,inform:[0,6],initi:6,integr:5,integrand:6,interpol:2,interpolate_hermit:2,interv:6,iter:6,jahr:1,jesu:1,johann:6,kalend:1,kalendarisch:1,keim:1,kepler:6,keplersch:6,keyword:2,kutta:6,kwarg:[2,3],kx1:0,lambda:6,ldot:6,left:[2,6],leftrightarrow:6,length:[0,2,7],leq:6,lhd:2,limit:6,limits_:6,limits_a:6,line:2,list:[0,2,6],lns:3,load:0,local:6,lower:6,lst:0,lvd:2,lvert:6,march:1,mathmat:6,mathrm:6,matplotlib:3,max_iter:6,maximum:6,mean:6,method:6,minumum:0,minut:7,minutes_norm:7,model:6,modul:[4,5],mondai:1,mondparamet:1,mondschaltung:1,mxn:0,ndarrai:6,necessari:6,necessarili:6,newmark:6,newmark_newtonraphson:6,newmark_newtonraphson_rdk:6,node:2,none:[0,6],normal:7,number:[2,6],numer:5,numerisch:6,numpi:6,object:[0,2],object_data:0,ode:5,ode_model:5,offset:[6,7],one:[0,2,6],option:2,order:[2,6],ordinari:6,org:1,origin:2,osterentfernung:1,osterformel:1,ostergrenz:1,ostersonntag:1,other:2,otherwis:2,packag:5,page:4,paramet:[0,1,2,6,7],pentecost:1,per:6,plane:2,plot:2,plot_cubic_lin:3,plot_lin:[2,3],plotter:3,point1:2,point1_i:2,point1_x:2,point2:2,point2_i:2,point2_x:2,point3:2,point4:2,point:[2,6],point_i:2,point_x:2,points1_i:2,points_to_xi:[],polygon:2,polygonzugverfahren:6,popt:6,posit:6,position_norm:7,print:[2,6],problem:6,program:0,proport:6,pts:2,pylab:3,quad:6,quadratur:6,radian:2,rang:7,read:0,rearrang:[],rectangl:2,residuum:6,rhd:2,right:[2,6],roation:2,rotat:[2,6],rotate_deg:2,rotate_xi:2,rotation_plan:2,rule:6,rung:6,rvd:2,rvert:6,sampl:2,sample_point1_x:2,sample_point2_i:2,sample_point2_x:2,sample_points1_i:2,save_valu:6,scale_i:2,scale_x:2,sche:6,search:4,second:[0,6,7],seconds_norm:7,segment:6,set:6,should:2,side:6,sigma:6,simpson:6,simpsonregel:6,size:[2,6],slope:2,solid:2,solut:6,solv:6,solver:6,sonnenschaltung:1,sonntag:1,sourc:[0,1,2,3,6,7],space:6,spacial:1,special:6,specifi:6,sqrt:6,squar:[2,6],stabl:6,standard:6,start:2,step:6,store:0,str:0,string:2,struct_tim:7,subinterv:6,submodul:5,sum:6,sundai:1,system:[2,6],t_0:6,t_i:6,tabl:2,tagen:1,text:6,than:2,therefor:6,thi:2,thick:6,thoma:6,ti1:6,time:[6,7],time_norm:7,time_of_dai:5,tol:6,toler:6,top:2,torqu:6,transform:7,translat:2,translate_xi:2,trapez:6,trapezium:6,trapezoid:6,trapezregel:6,tupl:[0,2,6],two:[0,2,6],type:[0,1,2,6,7],uid:0,uniqu:0,unique_end:0,upper:6,used:6,using:[3,6],usw:1,valu:[6,7],varepsilon:6,variabl:[1,6],varianc:6,vec:2,vector:2,veloc:6,verbos:[0,6],verfahren:6,vert_0:6,vert_a:6,vertcal:2,vertic:[2,6],vollmond:1,von:1,what:2,where:6,which:6,width:[2,6],wiki:1,wikipedia:1,wise:2,write:0,x_0:6,x_1:[2,6],x_2:[2,6],x_column:0,x_fit:6,x_i:6,x_n:6,xp0:6,xpn:6,xpp0:6,xppn:6,y_1:2,y_2:2,y_column:0,y_fit:6,year:[1,7],yet:[]},titles:["data module","date module","geometry module","geometry_plot module","Welcome to pylib\u2019s documentation!","src","numerical package","time_of_day module"],titleterms:{content:6,data:0,date:1,document:4,fit:6,geometri:2,geometry_plot:3,indic:4,integr:6,modul:[0,1,2,3,6,7],numer:6,ode:6,ode_model:6,packag:6,pylib:4,src:5,submodul:6,tabl:4,time_of_dai:7,welcom:4}}) \ No newline at end of file +Search.setIndex({docnames:["data","date","geometry","geometry_plot","index","modules","numerical","time_of_day"],envversion:{"sphinx.domains.c":1,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":1,"sphinx.domains.javascript":1,"sphinx.domains.math":2,"sphinx.domains.python":1,"sphinx.domains.rst":1,"sphinx.domains.std":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["data.rst","date.rst","geometry.rst","geometry_plot.rst","index.rst","modules.rst","numerical.rst","time_of_day.rst"],objects:{"":{data:[0,0,0,"-"],date:[1,0,0,"-"],fit:[6,0,0,"-"],geometry:[2,0,0,"-"],geometry_plot:[3,0,0,"-"],integration:[6,0,0,"-"],numerical:[6,0,0,"-"],ode:[6,0,0,"-"],ode_model:[6,0,0,"-"],time_of_day:[7,0,0,"-"]},"numerical.fit":{gauss:[6,1,1,""],gauss_fit:[6,1,1,""]},"numerical.integration":{trapez:[6,1,1,""]},"numerical.ode":{e1:[6,1,1,""],e2:[6,1,1,""],e4:[6,1,1,""],fpi:[6,1,1,""],i1:[6,1,1,""],newmark_newtonraphson:[6,1,1,""],newmark_newtonraphson_rdk:[6,1,1,""]},"numerical.ode_model":{disk:[6,1,1,""],disk_nm:[6,1,1,""],disk_nmmdk:[6,1,1,""]},data:{fold_list:[0,1,1,""],get_id:[0,1,1,""],load:[0,1,1,""],read:[0,1,1,""],seq:[0,1,1,""],store:[0,1,1,""],unique_ending:[0,1,1,""],write:[0,1,1,""]},date:{"gau\u00dfsche_osterformel":[1,1,1,""],ascension_of_jesus:[1,1,1,""],easter_friday:[1,1,1,""],easter_monday:[1,1,1,""],easter_sunday:[1,1,1,""],pentecost:[1,1,1,""]},geometry:{angle:[2,1,1,""],cubic:[2,1,1,""],cubic_deg:[2,1,1,""],cubics:[2,1,1,""],distance:[2,1,1,""],interpolate_hermite:[2,1,1,""],line:[2,1,1,""],lines:[2,1,1,""],rectangle:[2,1,1,""],rotate:[2,1,1,""],rotate_deg:[2,1,1,""],rotate_xy:[2,1,1,""],square:[2,1,1,""],translate:[2,1,1,""],translate_xy:[2,1,1,""]},geometry_plot:{plot_cubic_lines:[3,1,1,""],plot_lines:[3,1,1,""]},numerical:{fit:[6,0,0,"-"],integration:[6,0,0,"-"],ode:[6,0,0,"-"],ode_model:[6,0,0,"-"]},time_of_day:{days:[7,1,1,""],days_norm:[7,1,1,""],hours:[7,1,1,""],hours_norm:[7,1,1,""],in_seconds:[7,1,1,""],minutes:[7,1,1,""],minutes_norm:[7,1,1,""],seconds:[7,1,1,""],seconds_norm:[7,1,1,""],transform:[7,1,1,""]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:function"},terms:{"1st":6,"2nd":6,"4th":6,"9fsche_osterformel":1,"case":6,"char":0,"default":[0,2,6,7],"f\u00fcr":1,"float":[0,2,6,7],"fr\u00fchling":1,"function":6,"gau\u00dfsch":1,"gau\u00dfsche_osterformel":1,"int":[0,1,2,6],"korrekturgr\u00f6\u00df":1,"m\u00e4rz":1,"m\u00e4rzdatum":1,"new":7,"return":[0,1,2,6,7],"s\u00e4kular":1,"s\u00e4kularzahl":1,"vorw\u00e4rt":6,Das:1,The:[0,2,6,7],absolut:2,addit:2,against:6,algorithmu:1,als:1,alwai:[],amplitud:6,analyt:6,angl:2,angle1:2,angle2:2,approx:6,approxim:6,april:1,area:6,argument:2,arithmet:0,around:2,arrai:0,ascens:1,ascension_of_jesu:1,ascii:0,assum:2,assumend:[],averag:7,backward:6,base:6,becom:6,begin:6,beta:6,between:[0,2],binari:0,bmatrix:6,bool:[0,6],bottom:2,bound:0,boundari:2,build:2,calcul:[1,6,7],cauchi:6,cdot:6,center:2,chang:2,choos:6,close:0,column:0,common:0,composit:6,condit:[2,6],consecut:0,constant:0,content:5,convert:[0,7],coordin:2,counterclockwis:2,creat:0,cubic:2,cubic_deg:2,dai:[1,7],data:[5,6],date:[0,2,3,5,6,7],datetim:1,datum:1,days_norm:7,ddot:6,decid:2,defin:2,definit:6,deflect:2,deform:2,degener:0,degre:2,den:1,der:1,derform:2,deriv:6,des:1,describ:6,deviat:6,diamet:6,die:1,differ:[0,6],differenti:6,dimension:0,dimenson:0,direct:2,disk:6,disk_nm:6,disk_nmmdk:6,displac:[2,6],distanc:2,distribut:6,divid:6,doe:2,dot:6,each:2,easter:1,easter_fridai:1,easter_mondai:1,easter_sundai:1,eccentr:6,edg:2,either:2,element:[0,2],empti:0,emptyset:0,end:[0,2,6],endpoint:2,entfernung:1,equal:6,equalii:6,equat:6,error:6,ersten:1,euler:6,everi:6,exampl:[2,6],expect:6,explicit:6,explizit:6,f_n:6,factor:2,fail:0,fals:[0,6],fassregel:6,file:0,file_nam:0,filenam:0,first:[0,2,6],fit:5,fix:6,float64:6,fnm:6,fold_list:0,follow:0,foral:6,forward:6,fourth:6,fpi:6,frac:[2,6],fridai:1,from:[0,6],full:[0,6],fwhm:6,gamma:6,gau:1,gauss:6,gauss_fit:6,geometri:[3,5],geometry_plot:[2,5],get:0,get_id:0,gilt:1,given:[0,2,6],global:[2,6],global_deform:2,govern:6,gregorian:7,gregorianischen:1,half:6,has:[0,6],height:2,hermit:2,horizont:2,hour:7,hours_norm:7,http:1,ids:0,implement:[],implicit:6,in_second:7,inc:2,incid:2,index:[0,2,4],index_offset:2,inform:[0,6],initi:6,integr:5,integrand:6,interpol:2,interpolate_hermit:2,interpret:0,interv:6,iter:6,jahr:1,jesu:1,johann:6,kalend:1,kalendarisch:1,keim:1,kepler:6,keplersch:6,keyword:2,kutta:6,kwarg:[2,3],kx1:0,lambda:6,ldot:6,left:[0,2,6],leftrightarrow:6,length:[0,2,7],leq:6,lhd:2,limit:6,limits_:6,limits_a:6,line:2,list:[0,2,6],lns:3,load:0,local:6,lower:[0,6],lst:0,lvd:2,lvert:6,manipul:0,march:1,mathmat:6,mathrm:6,matplotlib:3,max_iter:6,maximum:6,mean:6,method:6,minumum:0,minut:7,minutes_norm:7,model:6,modul:[4,5],mondai:1,mondparamet:1,mondschaltung:1,mxn:0,ndarrai:6,necessari:6,necessarili:6,newmark:6,newmark_newtonraphson:6,newmark_newtonraphson_rdk:6,node:2,none:[0,2,6],normal:7,number:[2,6],numer:5,numerisch:6,numpi:6,object:[0,2],object_data:0,ode:5,ode_model:5,offset:[6,7],one:[0,2,6],onli:0,open:0,option:2,order:[2,6],ordinari:6,org:1,origin:2,osterentfernung:1,osterformel:1,ostergrenz:1,ostersonntag:1,other:2,otherwis:2,packag:5,page:4,paramet:[0,1,2,6,7],pentecost:1,per:6,plane:2,plot:2,plot_cubic_lin:3,plot_lin:[2,3],plotter:3,point1:2,point1_i:2,point1_x:2,point2:2,point2_i:2,point2_x:2,point3:2,point4:2,point:[2,6],point_i:2,point_x:2,points1_i:2,points_to_xi:[],polygon:2,polygonzugverfahren:6,popt:6,posit:6,position_norm:7,print:[2,6],problem:6,program:0,proport:6,pts:2,pylab:3,quad:6,quadratur:6,radian:2,rang:7,read:0,rearrang:[],rectangl:2,residuum:6,rhd:2,right:[0,2,6],roation:2,rotat:[2,6],rotate_deg:2,rotate_xi:2,rotation_plan:2,rule:6,rung:6,rvd:2,rvert:6,same:0,sampl:2,sample_point1_x:2,sample_point2_i:2,sample_point2_x:2,sample_points1_i:2,save_valu:6,scale_i:2,scale_x:2,sche:6,search:4,second:[0,2,6,7],seconds_norm:7,segment:6,seq:0,sequenc:0,set:6,should:2,side:6,sigma:6,simpson:6,simpsonregel:6,size:[0,2,6],slope:2,solid:2,solut:6,solv:6,solver:6,sonnenschaltung:1,sonntag:1,sourc:[0,1,2,3,6,7],space:6,spacial:1,special:6,specifi:6,sqrt:6,squar:[2,6],stabl:6,standard:6,start:[0,2],step:[0,6],stop:0,store:0,str:0,straight:2,string:2,struct_tim:7,structur:0,subinterv:6,submodul:5,sum:6,sundai:1,system:[2,6],t_0:6,t_i:6,tabl:2,tagen:1,term:0,text:6,than:[0,2],therefor:6,thi:2,thick:6,thoma:6,ti1:6,time:[6,7],time_norm:7,time_of_dai:5,tol:6,toler:6,top:2,torqu:6,transform:7,translat:2,translate_xi:2,trapez:6,trapezium:6,trapezoid:6,trapezregel:6,tupl:[0,2,6],two:[0,2,6],type:[0,1,2,6,7],uid:0,uniqu:0,unique_end:0,upper:[0,6],used:6,using:[3,6],usw:1,valu:[6,7],varepsilon:6,variabl:[1,6],varianc:6,vec:2,vector:2,veloc:6,verbos:[0,6],verfahren:6,vert_0:6,vert_a:6,vertcal:2,vertic:[2,6],vollmond:1,von:1,what:2,where:6,which:6,width:[2,6],wiki:1,wikipedia:1,wise:2,write:0,x_0:6,x_1:[2,6],x_2:[2,6],x_column:0,x_fit:6,x_i:6,x_n:6,xp0:6,xpn:6,xpp0:6,xppn:6,y_1:2,y_2:2,y_column:0,y_fit:6,year:[1,7],yet:[]},titles:["data module","date module","geometry module","geometry_plot module","Welcome to pylib\u2019s documentation!","src","numerical package","time_of_day module"],titleterms:{content:6,data:0,date:1,document:4,fit:6,geometri:2,geometry_plot:3,indic:4,integr:6,modul:[0,1,2,3,6,7],numer:6,ode:6,ode_model:6,packag:6,pylib:4,src:5,submodul:6,tabl:4,time_of_dai:7,welcom:4}}) \ No newline at end of file diff --git a/src/data.py b/src/data.py index a7b3fc0..712ca45 100644 --- a/src/data.py +++ b/src/data.py @@ -1,12 +1,12 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -"""Read and write data to or from file. +"""Read and write data to or from file and manipulate data structures. -:Date: 2019-07-29 +:Date: 2019-10-11 .. module:: data :platform: *nix, Windows - :synopsis: Handle data files. + :synopsis: Handle data files and structures. .. moduleauthor:: Daniel Weschke """ @@ -120,6 +120,40 @@ def fold_list(lst, n): length = int(k/n) return [lst[i*n:i*n+n] for i in range(length)] +def seq(start, stop=None, step=1): + r"""Create an arithmetic bounded sequence. + + The sequence is one of the following; + + - empty :math:`\{\}=\emptyset`, if start and stop are the same + - degenerate :math:`\{a\}`, if the sequence has only one element. + - left-close and right-open :math:`[a, b)` + + :param start: start of the sequence, the lower bound. If only start + is given than it is interpreted as stop and start will be 0. + :type start: int or float + :param stop: stop of sequence, the upper bound. + :type stop: int or float + :param step: step size, the common difference (constant difference + between consecutive terms). + :type step: int or float + :returns: arithmetic bounded sequence + :rtype: list + """ + if stop is None: + return seq(0, start, step) + + step_str = str(step) + exponent = 0 + if '.' in step_str: + exponent = len(step_str.split('.')[1]) + + n = int(math.ceil((stop - start)/float(step))) + lst = [] + if n > 0: + lst = [round(start + step*i, exponent) for i in range(n)] + return lst + def unique_ending(ids, n=1): """From id list get list with unique ending.