python - vmin vmax algorithm matplotlib -


i write script calibration of image (dark frame , flat field)...here part of code

for n in range(len(img)): pyfits.open(img[n],mode='update',memmap=true) im:     imgg=im[0].data     header=im[0].header     imgg.astype(float)     imgg=(imgg-dd)/df     imgg[np.isnan(imgg)]=1     imgg.astype(int)     plt.imshow(imgg,cmap=plt.cm.greys_r,vmin=0.5,vmax=1.5)     plt.show() 

this part of code make calibration of image dark frame , flat field...when use @ plotting vmin vmax right picture dont know how vmin , vmax work.i need apply on image data (imgg) because when save data images without vmin vmax...

any suggestion?

and second question ...how can save data changes in fits files? when used im.close() work on 1 file dont work in loop.

thanks

edit

ok here full script

import numpy np import pyfits matplotlib import pyplot plt import glob   dark=glob.glob('.../ha/dark/*.fits') flat=glob.glob('.../ha/flat/*.fits') img=glob.glob('.../ha/*.fits')  sumd0 = pyfits.open(dark[0]) sumdd=sumd0[0].data sumdd.astype(float) in range(1,len(dark)):      sumdi=pyfits.open(dark[i])      sumdi=sumdi[0].data      sumdd=sumdd.astype(float)+sumdi.astype(float) dd=sumdd/len(dark)  sumf0 = pyfits.open(flat[0]) sumff=sumf0[0].data sumff.astype(float) in range(1,len(flat)):      sumfi=pyfits.open(flat[i])      sumfi=sumfi[0].data      sumff=sumff.astype(float)+sumfi.astype(float)  ff=sumff/len(flat)  df=(ff-dd)  n in range(len(img)):     pyfits.open(img[n],mode='update',memmap=true) im:         imgg=im[0].data         header=im[0].header         imgg.astype(float)         imgg=(imgg-dd)/df         imgg.astype(int) plt.imshow(imgg,cmap=plt.cm.greys_r,vmin=0.5,vmax=1.5) plt.show() 

a bit ofuscated question think want (from comment in other answer).

to clamp data same behaviour vmin , vmax, use np.clip:

np.clip(data, min, max) 

in case:

data = np.clip(data, 0.5, 1.5) 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -