Program OVN_copy ! A.Bijaoui 23 February 2006 ! Corrections 03/11/09 ! Extraction of an image zone ! The whole image is read Implicit None Integer Lu,Nc,Nl,Bp,Nodef,Status,Npix,Ipix,Ikeys,Nkeys,Err Real Xd,Yd,Dx,Dy Integer Nc1,Nc2,Nc3,Ncs,Nl1,Nl2,Nl3,Nls,Nps Character FileIn*40,String*80,Comment*60,Mouch*40,FileOut*40 Real,dimension(:),allocatable:: Lect,Ecr Character Option(50)*100 Call Getline(Nkeys,Option) Nc1=1 Nc3=1 Nl1=1 Nl3=1 Nc2=0 Nl2=0 FileIn=" " FileOut=" " Mouch='mouch.lis' If(Nkeys.eq.0) then Write(*,*) 'Syntax : -i Image_in -c1 Start_Column -c2 End_Column -c3 Column_Step' Write(*,*) ' -l1 Start_line -l2 Last_line -l3 Step_Column' Write(*,*) ' -o Image_Zone -l logfile' Write(*,*) 'Extraction of an image zone' Write(*,*) '-i Image_in (required)' Write(*,*) '-c1 First column (def. 1)' Write(*,*) '-c2 Last column (def. number of columns)' Write(*,*) '-c3 Step between two extracted columns (def. 1)' Write(*,*) '-l1 First line (def. 1)' Write(*,*) '-l2 Last line (def. number of lines)' Write(*,*) '-l3 Step between two extracted liness (def. 1)' Write(*,*) '-o Image of the zone (required)' Write(*,*) '-l logfile : name of the log file (def. mouch.lis)' Stop Endif Do Ikeys=1,Nkeys,2 if(Option(Ikeys).eq.'-i') FileIn =Option(Ikeys+1) if(Option(Ikeys).eq.'-c1') Read(Option(Ikeys+1),*) Nc1 if(Option(Ikeys).eq.'-c2') Read(Option(Ikeys+1),*) Nc2 if(Option(Ikeys).eq.'-c3') Read(Option(Ikeys+1),*) Nc3 if(Option(Ikeys).eq.'-l1') Read(Option(Ikeys+1),*) Nl1 if(Option(Ikeys).eq.'-l2') Read(Option(Ikeys+1),*) Nl2 if(Option(Ikeys).eq.'-l3') Read(Option(Ikeys+1),*) Nl3 if(Option(Ikeys).eq.'-o') FileOut =Option(Ikeys+1) if(Option(Ikeys).eq.'-l') Mouch =Option(Ikeys+1) Enddo If(FileIn.eq." ") Stop "No image" If(FileOut.eq." ") Stop "No file for the image zone" Call Debut('OVN_copy',Mouch) Call WC('Extraction of an image zone') Call WC('Image to process '// FileIn) Status=0 Lu=1 Call OFits(Lu,FileIn,Bp,String,Nc,Nl,Dx,Dy,Xd,Yd) If(BP.ne.-32) Stop 'This program processes only real data' Npix=Nc*Nl Allocate(Lect(Npix),stat=err) ; If(err/=0) Stop "Allocation problem" Call FtgpvE(Lu,0,1,Npix,0,Lect,Nodef,Status) Call FTClos(Lu,Status) Call FTFiou(Lu,Status) If(Nc2.eq.0) Nc2=Nc Write(String,*)'From column ',Nc1,' To Column ',Nc2,' Step ',Nc3 Call WC(String) Ncs=(Nc2-Nc1)/Nc3+1 If(Nl2.eq.0) Nl2=Nl Write(String,*)'From line ',Nl1,' To line ',Nl2,' Step ',Nl3 Call WC(String) Nls=(Nl2-Nl1)/Nl3+1 Nps=Ncs*Nls Allocate(Ecr(Nps),stat=err) ; If(err/=0) Stop "Allocation problem" Call Extract(Lect,Nc,Nl,Nc1,Nc2,Nc3,Nl1,Nl2,Nl3,Nls,Ncs,Ecr) Call WC('Image of the zone '//FileOut) Xd=(Nc1-1)*Dx Yd=(Nl1-1)*Dy Dx=Nc3*Dx Dy=Nl3*Dy Comment='Zone extracted by OVN_copy' Call CFits(FileOut,Lu,Comment,Ncs,Nls,Dx,Dy,Xd,Yd,BP) Call FtpprE(Lu,0,1,Nps,Ecr,Status) Call FTClos(Lu,Status) CALL LAFIN('OVN_copy') END Subroutine Extract(Lect,Nc,Nl,Nc1,Nc2,Nc3,Nl1,Nl2,Nl3,Nls,Ncs,Ecr) Implicit None Integer Nc,Nl,Nc1,Nc2,Nc3,Nl1,Nl2,Nl3,Nls,Ncs,Ils,Ics,Ic,Il Real Lect(Nc,Nl),Ecr(Ncs,Nls) Ils=0 Do Il=Nl1,Nl2,Nl3 Ils=Ils+1 Ics=0 Do Ic=Nc1,Nc2,Nc3 Ics=Ics+1 Ecr(Ics,Ils)=Lect(Ic,Il) Enddo Enddo Return End