ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/osprai/osprai/trunk/cal_module.py
(Generate patch)
# Line 2 | Line 2
2   cal: Calibration module for SPRI data in a ba class.
3   Christopher Lausted, Institute for Systems Biology,
4   OSPRAI developers
5 < Last modified on 100413 (yymmdd)
5 > Last modified on 101116 (yymmdd)
6  
7   Example:
8   #import cal_module as cal
# Line 13 | Line 13
13   #cal.bgset(ba2, bgroi)
14   #ba3 = cal.bgsubt(ba2)
15   """
16 < __version__ = "100413"
16 > __version__ = "100426"
17  
18  
19   ## Import libraries
# Line 69 | Line 69
69      return
70      ## End of bgset().
71  
72 +
73 + def copyinterval(ba0, t1, t2):
74 +    """Copy data from the interval between t1 and t2 and return a new ba object."""
75 +    ba1 = deepcopy(ba0)
76 +    for i in range(len(ba0.roi)):
77 +        dp1 = ba0.roi[i].time2dp(t1)
78 +        dp2 = ba0.roi[i].time2dp(t2)
79 +        ba1.roi[i].time = ba1.roi[i].time[dp1:dp2]
80 +        ba1.roi[i].value = ba1.roi[i].value[dp1:dp2]
81 +    return ba1
82 +    ## End of copyinterval().
83 +
84 +
85 + def zerotime(ba):
86 +    """Adjust sensorgrams to start at time[0]=0."""
87 +    for roi in ba.roi:
88 +        if (len(roi.time) > 0):
89 +            roi.time -= roi.time[0]
90 +    return
91 +    ## End of zerotime().
92 +    
93 +    
94 + def zerovalue(ba):
95 +    """Adjust sensorgrams to start at value[0]=0."""
96 +    for roi in ba.roi:
97 +        if (len(roi.value) > 0):
98 +            roi.value -= roi.value[0]
99 +    return
100 +    ## End of zerovalue().
101 +
102   ################################# End of module #################################

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines