Visualize a specific field of structure for all elements in a cell array
1 view (last 30 days)
Show older comments
Lorenzo Limonta
on 19 Jul 2015
Commented: Lorenzo Limonta
on 19 Jul 2015
Hi everyone,
Does anyone know how access a specific field of all the structures in a cell array? Let me explain better, I have the following function:
function [star] = GetMagAndPixelsForBrightStars( inputFile,Nxpix,Nypix,limiting_mag)
that gives me a list of stars with some characteristics, i.e.
star{1}
ans =
Name: '4559-558-1'
Tycho1: 4559
Tycho2: 558
Tycho3: 1
Xpixel: 189
Ypixel: 486
BTmag: 9.9770
BTsigma: 0.0220
VTmag: 8.9730
VTsigma: 0.0140
HPmag: 0
HPsigma: 0
Frame: '905000'
would it be possible to visualize only BTmag for all the stars - without going through a for loop - meaning smtg along the line: star{:}.BTmag where I visualize all the BT magnitudes for the star in the cell array?
Thanks,
Best regards
%%%%Complete code
function [star] = GetMagAndPixelsForBrightStars( inputFile,Nxpix,Nypix,limiting_mag)
% Input
% inputFile= absolute path of where the astronometry bright star path txt
% baseline_data_file= path to where the data for the given frame is being
% Nxpix,Nypix Number of xpixels and ypixels in the image
% analyzed
% file is
% tycho.fits = absolute path of where the tycho2 fits table is
% Output
% star.NameTycho1=First Digit of the tycho denomination
% star.NameTycho2=Second Digit of the tycho denomination
% star.NameTycho3=Third Digit of the tycho denomination
% star.Xpixel,Ypixel= location of the star at the given frame
% star.Frame = where we are detecting the star
%
%
% Load the Tycho-2 fits columns with the tychos numbers so that we can get
% the BT, VT magnitudes (columns from 24 to
TychosNameTable=fitsread('/home/limo/PHD/Astrometry/astrometry.net-0.50/catalogs/tycho2.fits','binarytable','TableColumns',[1:3,25:30]);
% if you cannot load the entire table uncomment the following and comment
% out the line above
% TychosNameTable=fitsread('/home/limo/PHD/Astrometry/astrometry.net-0.50/catalogs/tycho2.fits','binarytable','TableColumns',[1:3]);
% The structure of the above fits file is the following
% C1 C2 C3 C4 C5 C6 C7 C8 C9 C10
% TYC1 TYC2 TYC3 RA DEC MEAN_RA MEAN_DEC SIGMA_RA SIGMA_DEC SIGMA_MEAN_RA
% C11 C12 C13 C14 C15 C16 C17
% SIGMA_MEAN_DEC PM_RA PM_DEC SIGMA_PM_RA SIGMA_PM_DEC EPOCH_RA EPOCH_DEC
% C18 C19 C20 C21 C22 C23
% EPOCH_MEAN_RA EPOCH_MEAN_DEC NOBS GOODNESS_MEAN_ GOODNESS_MEAN_ GOODNESS_PM_RA
% C24 C25 C26 C27 C28 C29 C30
% GOODNESS_PM_DE MAG_BT SIGMA_MAG_BT MAG_VT SIGMA_MAG_VT MAG_HP SIGMA_MAG_HP
% C31 C32 C33 C34 C35
% PROX CORRELATION HIPPARCOS_I CCD FLAGS
infile=fileread(inputFile);
[tempFrame]=regexp(infile,'[*](\d+)[*]','match');
[tempFrame]=regexp(tempFrame,'(\d+)','match'); %excluding the '*' characters
Frame=char(tempFrame{1});
counter_star=0;
TychoNames=regexp(infile,'(\d+)-(\d+)-(\d+)','match'); %looking in the file where the tycho-2 name is since we know that the format is number-number-number we look for that!
[dummy,BegXp]=regexp(infile,'"], "pixelx": '); %looking in the file where the pixelx word begins and end. Looking at the inputFile where xpixel begins is where tycho-2 reference number ends
BegXp=BegXp+1; %Adding one because the above line gives the position to the space
[EndXp,BegYp]=regexp(infile,', "pixely": '); %looking in the file where the pixely word begins and end. Looking at the inputFile where ypixel ends is where xpixel number ends
EndXp=EndXp-1; %Subtractiong minus one because the above line gives location of the ' , ' character
BegYp=BegYp+1;
for iii=1:length(TychoNames)
Name=TychoNames(iii);
[tempNumbers]=regexp(Name,'(\d+)','match');
Tycho1=str2double(tempNumbers{1}(1));
Tycho2=str2double(tempNumbers{1}(2));
Tycho3=str2double(tempNumbers{1}(3));
dummy1=find(TychosNameTable{1}(:)==Tycho1);
dummy2=find(TychosNameTable{2}(dummy1)==Tycho2); % This allow me to find in which row is the star located in the table
StarTemp=[TychosNameTable{1}(dummy1(dummy2)),TychosNameTable{2}(dummy1(dummy2)),TychosNameTable{3}(dummy1(dummy2)), ...
TychosNameTable{4}(dummy1(dummy2)),TychosNameTable{5}(dummy1(dummy2)),TychosNameTable{6}(dummy1(dummy2)), ...
TychosNameTable{7}(dummy1(dummy2)),TychosNameTable{8}(dummy1(dummy2)),TychosNameTable{9}(dummy1(dummy2))];
%
%If you cannot load the entire table comment out the above line
%and uncomment the following two
% StarDummy=fitsread('/home/limo/PHD/Astrometry/astrometry.net-0.50/catalogs/tycho2.fits','binarytable','TableColumns',[1:3,25:30],'TableRows',dummy1(dummy2));
% StarTemp=[StarDummy{:}];
% star temp has the following format:
%C1 C2 C3 C4 C5 C6 C7 C8 C9
% TYC1 TYC2 TYC3 MAG_BT SIGMA_MAG_BT MAG_VT SIGMA_MAG_VT MAG_HP SIGMA_MAG_HP
xpix=str2double(infile(BegXp(iii):EndXp(iii)));
ypix=str2double(infile(BegYp(iii):BegYp(iii)+12));
if (StarTemp(4)<limiting_mag) && (StarTemp(6)<limiting_mag) && StarTemp(9)<limiting_mag && (xpix>10 && xpix<(Nxpix-10)) && (ypix>10 && ypix<(Nypix-10))
counter_star=counter_star+1;
star{counter_star}.Name=char(TychoNames(iii));
star{counter_star}.Tycho1=StarTemp(1);
star{counter_star}.Tycho2=StarTemp(2);
star{counter_star}.Tycho3=StarTemp(3);
star{counter_star}.Xpixel=round(str2double(infile(BegXp(iii):EndXp(iii))));
star{counter_star}.Ypixel=round(str2double(infile(BegYp(iii):BegYp(iii)+12)));
star{counter_star}.BTmag=StarTemp(4);
star{counter_star}.BTsigma=StarTemp(5);
star{counter_star}.VTmag=StarTemp(6);
star{counter_star}.VTsigma=StarTemp(7);
star{counter_star}.HPmag=StarTemp(8);
star{counter_star}.HPsigma=StarTemp(9);
star{counter_star}.Frame=Frame;
[luminosity]=StarPixelCount(xpixel,ypixel,framename);
star{counter_star}.Luminosity=luminosity;
end
end
end
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Classical Control Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!