These are chat archives for BernieenJos/weetikveel

28th
May 2015
JosvanderSpek
@JosvanderSpek
May 28 2015 18:45
Yo

```subtracted_tail = []
background = pyfits.open('merged.fits')[0].data[40:510, 2820:2830]
pixelsx_bg = 10
pixelsy_bg = 470
tail = pyfits.open('merged.fits')[0].data[40:510, 2855:2930]
pixelsx_tail= 75
pixelsy_tail= 470

def Tail() :
for s in range(10) :
bg = []
integrated_tail_s = []
for j in range(sint(pixelsy_bg/10), (s+1)int(pixelsy_bg/10)):
for i in range(pixelsx_bg):
bg.append(background[j][i])
mean_bg = sum(bg)/(pixelsx_bgpixelsy_bg/10)
print(background)
print(tail)
for j in range(s
int(pixelsy_tail/10), (s+1)int(pixelsy_tail/10)):
for i in range(pixelsx_tail):
integrated_tail_s.append(tail[j][i]) # segment 's' integrated
subtracted_tail_s = sum(integrated_tail_s) - pixelsx_tail
(pixelsy_tail/10)*mean_bg # segment 's' integrated and subtracted bg
subtracted_tail.append(int(subtracted_tail_s))

tail = sum(subtracted_tail)    
print(tail)

Tail()
'''

He shit
a= 3
oh ja
subtracted_tail = []
background  = pyfits.open('merged.fits')[0].data[40:510, 2820:2830]
pixelsx_bg  = 10
pixelsy_bg  = 470
tail        = pyfits.open('merged.fits')[0].data[40:510, 2855:2930]
pixelsx_tail= 75
pixelsy_tail= 470   


def Tail() :
    for s in range(10) :
        bg = [] 
        integrated_tail_s = []
        for j in range(s*int(pixelsy_bg/10), (s+1)*int(pixelsy_bg/10)):
            for i in range(pixelsx_bg):
                bg.append(background[j][i])
        mean_bg  = sum(bg)/(pixelsx_bg*pixelsy_bg/10)    
        print(background)
        print(tail)
        for j in range(s*int(pixelsy_tail/10), (s+1)*int(pixelsy_tail/10)):      
            for i in range(pixelsx_tail):       
                integrated_tail_s.append(tail[j][i])                                                    # segment 's' integrated
        subtracted_tail_s = sum(integrated_tail_s) - pixelsx_tail*(pixelsy_tail/10)*mean_bg             # segment 's' integrated and subtracted bg          
        subtracted_tail.append(int(subtracted_tail_s))

    tail = sum(subtracted_tail)    
    print(tail)



Tail()
krijg ik dit als output
[[  4.37563801   9.75996304  -5.37030888 ...,  19.38510323  -2.11669302
    1.38034248]
 [ 22.27758217   7.7754612   13.97601128 ...,  13.1654253   -9.59331894
   16.02331734]
 [  8.1102047   12.06427765  15.47949982 ...,  12.34007359  11.53682709
    4.23672342]
 ..., 
 [-19.46498108 -21.86507416 -21.42646408 ..., -10.45089436 -13.29083252
   27.82401466]
 [-14.84066582  15.79073334 -12.2840395  ...,  -7.78121376 -11.71316051
   13.24197292]
 [ 18.84876442 -19.91113091   2.33063555 ...,  -6.12456465  -5.53229523
    2.71241379]]
Traceback (most recent call last):
  File "Photometry.py", line 56, in <module>
    Tail()
  File "Photometry.py", line 44, in Tail
    print(tail)
Dus dat background globaal gedeclareerd wordt vindt-ie blijkbaar prima, maar tail -- die in mijn ogen EXACT hetzelfde gebruikt wordt als tail -- niet!
hetzelfde als background*
Oh shit vergeet ik de laatste regel van de error:
JosvanderSpek
@JosvanderSpek
May 28 2015 18:50
UnboundLocalError: local variable 'tail' referenced before assignment
iambernie
@iambernie
May 28 2015 18:51
Je kan berichten een paar minuten na verzenden nog editen trouwens.
JosvanderSpek
@JosvanderSpek
May 28 2015 18:51
Oh!
Ja ik zie het!
Goed
ik begin wel even opnieuw ander
Mijn code:
```
subtracted_tail = []
background  = pyfits.open('merged.fits')[0].data[40:510, 2820:2830]
pixelsx_bg  = 10
pixelsy_bg  = 470
tail        = pyfits.open('merged.fits')[0].data[40:510, 2855:2930]
pixelsx_tail= 75
pixelsy_tail= 470   


def Tail() :
    for s in range(10) :
        bg = [] 
        integrated_tail_s = []
        for j in range(s*int(pixelsy_bg/10), (s+1)*int(pixelsy_bg/10)):
            for i in range(pixelsx_bg):
                bg.append(background[j][i])
        mean_bg  = sum(bg)/(pixelsx_bg*pixelsy_bg/10)    
        print(background)
        print(tail)
        for j in range(s*int(pixelsy_tail/10), (s+1)*int(pixelsy_tail/10)):      
            for i in range(pixelsx_tail):       
                integrated_tail_s.append(tail[j][i])                                                    # segment 's' integrated
        subtracted_tail_s = sum(integrated_tail_s) - pixelsx_tail*(pixelsy_tail/10)*mean_bg             # segment 's' integrated and subtracted bg          
        subtracted_tail.append(int(subtracted_tail_s))

    tail = sum(subtracted_tail)    
    print(tail)



Tail()
```
De error:
[[  4.37563801   9.75996304  -5.37030888 ...,  19.38510323  -2.11669302
    1.38034248]
 [ 22.27758217   7.7754612   13.97601128 ...,  13.1654253   -9.59331894
   16.02331734]
 [  8.1102047   12.06427765  15.47949982 ...,  12.34007359  11.53682709
    4.23672342]
 ..., 
 [-19.46498108 -21.86507416 -21.42646408 ..., -10.45089436 -13.29083252
   27.82401466]
 [-14.84066582  15.79073334 -12.2840395  ...,  -7.78121376 -11.71316051
   13.24197292]
 [ 18.84876442 -19.91113091   2.33063555 ...,  -6.12456465  -5.53229523
    2.71241379]]
Traceback (most recent call last):
  File "Photometry.py", line 56, in <module>
    Tail()
  File "Photometry.py", line 44, in Tail
    print(tail)
UnboundLocalError: local variable 'tail' referenced before assignment
Dus background wordt gewoon netjes geprint, maar tail 'is referenced before assignment'
Op zich prima, MAAR DAN IS BACKGROUND DAT TOCH OOK!!!??
iambernie
@iambernie
May 28 2015 18:55
Wat gebeurt er als je deze twee statements omdraait?
        print(background)
        print(tail)
JosvanderSpek
@JosvanderSpek
May 28 2015 18:57
Kijk, dit is dus weer iets wat ik nooit bedacht had. Dat kan natuurlijk onmogelijk uitmaken. ;) Zal het toch even proberen
Traceback (most recent call last):
  File "Photometry.py", line 56, in <module>
    Tail()
  File "Photometry.py", line 43, in Tail
    print(tail)
UnboundLocalError: local variable 'tail' referenced before assignment
Nee, dan loopt hij dus idd vast voordat background de kans krijgt geprint te worden
Op zich is het ook niet heel erg, want als ik hem gewoon zo in Tail() plaats doet hij het gewoon
subtracted_tail = []
background  = pyfits.open('merged.fits')[0].data[40:510, 2820:2830]
pixelsx_bg  = 10
pixelsy_bg  = 470
pixelsx_tail= 75
pixelsy_tail= 470   


def Tail() :
    tail = pyfits.open('merged.fits')[0].data[40:510, 2855:2930]
    for s in range(10) :
        bg = [] 
        integrated_tail_s = []
        for j in range(s*int(pixelsy_bg/10), (s+1)*int(pixelsy_bg/10)):
            for i in range(pixelsx_bg):
                bg.append(background[j][i])
        mean_bg  = sum(bg)/(pixelsx_bg*pixelsy_bg/10)    
        print(tail)
        print(background)
        for j in range(s*int(pixelsy_tail/10), (s+1)*int(pixelsy_tail/10)):      
            for i in range(pixelsx_tail):       
                integrated_tail_s.append(tail[j][i])                                                    # segment 's' integrated
        subtracted_tail_s = sum(integrated_tail_s) - pixelsx_tail*(pixelsy_tail/10)*mean_bg             # segment 's' integrated and subtracted bg          
        subtracted_tail.append(int(subtracted_tail_s))

    tail = sum(subtracted_tail)    
    print(tail)



Tail()
Maar ik vond het een bizarre gedraging
(Van Python)
iambernie
@iambernie
May 28 2015 19:06
Kun je me het script even mailen?
JosvanderSpek
@JosvanderSpek
May 28 2015 19:25
Jup
iambernie
@iambernie
May 28 2015 19:29
Kun je merged.fits ook sturen of is het supergroot?
JosvanderSpek
@JosvanderSpek
May 28 2015 20:10
zal ik doen
iambernie
@iambernie
May 28 2015 20:17
:point_up: May 28 2015 8:57 PM Ik krijg deze error niet als ik Photometry.py run
JosvanderSpek
@JosvanderSpek
May 28 2015 21:01
Oh space