Saturday 3 October 2015

Complete Procedure 1.0

STEP1: RESIZE to 2032x2032


In the folder where you have all the original JPEG images:


 for file in *.jpg; do convert $file -resize 2032x2032 resized_$file; done


STEP2: CONVERT to .fits files

a. Move the resized JPEGS to a new folder and convert them to .fits files:

        for file in *.jpg; do convert $file $file.fits; done

b. Create a list of the resized_ filenames for the next step:

        ls | grep -i "resized" > filenames.txt

STEP3:  Extract the TIME, DATE, Solar disk CENTER(X,Y) and disk RADIUS from resized JPEG images in MATLAB

<date_time_circles.m>

[names]=strcolread('filenames.txt',153,42);
% 153= # of files
% 42= length of the string of each filename
% (including a return at the end of each filename)

yy=names(:,23:26);      % Year
mm=names(:,27:28);   % Month
dd=names(:,29:30);     % Day
hh=names(:,32:33);     % Hours
min=names(:,34:35);   % Minutes
ss=names(:,36:37);      % Seconds

for n=1:153
timeobs(n,:)=[hh(n,:),':',min(n,:),':',ss(n,:)];
dateobs(n,:)=[yy(n,:),'-',mm(n,:),'-',dd(n,:)];
date_obs(n,:)=[yy(n,:),'-',mm(n,:),'-',dd(n,:),'T',hh(n,:),':',min(n,:),':',ss(n,:),'.000Z'];
end

data=horzcat(timeobs,dateobs,date_obs);
dlmwrite('date_time.txt',data,'delimiter','');

% Extracting the Center of the Solar Disk and its radius:

for n=1:153
[centers(n,:), radii(n), metric(n)] = imfindcircles(imread(sprintf(names(n,1:end-1))), [950 1000], ...
'Sensitivity',0.9900,'EdgeThreshold',0.01,'Method','TwoStage','ObjectPolarity', 'Bright');
end

centers(:,3)=radii';
centers2=round(centers);
fileid=fopen('circle_info.txt','w')
for n=1:153
fprintf(fileid,'%d %d %d\n',centers2(n,1),centers2(n,2),centers2(n,3));
end
fclose(fileid);



This routine will take hours to run for more than 150 files.

Move the new files <date_time.txt> and <circle_info.txt> to the folder containing the converted .fits files

<date_time.txt>  should have a single column of stings joined together.


STEP4: Appending the header

a. Create a list of all file names for .fits files:

         ls | grep -i "fits" > filenames.txt

b. Move the file <edit_header.py> to the directory containing all .fits files, <filenames.txt>, <date_time.txt> and <circle_info.txt>.

c. Change the number of filenames in the Python code to be equal to the entries you have in <filenames.txt>

d. Open a terminal and type:

         chmod +x edit_header.py

         ./edit_header.py


And watch magic happen, the headers of all .fits files are changed!

No comments:

Post a Comment