Code covered by the BSD License  

Highlights from
SKY MAP (GUI)

image thumbnail

SKY MAP (GUI)

by

 

16 Mar 2012 (Updated )

A MATLAB software that shows the position and relative brightness of stars in the sky

SkyMap(varargin)
function varargout = SkyMap(varargin)
% SKYMAP M-file for SkyMap.fig
%      SKYMAP, by itself, creates a new SKYMAP or raises the existing
%      singleton*.
%
%      H = SKYMAP returns the handle to a new SKYMAP or the handle to
%      the existing singleton*.
%
%      SKYMAP('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in SKYMAP.M with the given input arguments.
%
%      SKYMAP('Property','Value',...) creates a new SKYMAP or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before SkyMap_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to SkyMap_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help SkyMap

% Last Modified by GUIDE v2.5 09-Oct-2010 12:18:15

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @SkyMap_OpeningFcn, ...
                   'gui_OutputFcn',  @SkyMap_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before SkyMap is made visible.
function SkyMap_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to SkyMap (see VARARGIN)

% Choose default command line output for SkyMap
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% SET THE DATE AND TIME DEFAULTS TO PRESENT
    DT=datestr(now);   % Present date & time in the format: 25-Jan-2009 HH:MM:SS
    set(handles.edit1,'String',datestr(date,10));  %Present year
    set(handles.edit2,'String',datestr(date,5)); %Present month (in numbers)
    set(handles.edit3,'String',DT(1:2)); %Present day of the month
    set(handles.edit4,'String',DT(13:14)); %Present Hour
    set(handles.edit5,'String',DT(16:17)); %Present Minute
    set(handles.edit6,'String',DT(19:20)); %Present Second
    

% UIWAIT makes SkyMap wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = SkyMap_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit4_Callback(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double


% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double


% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit7_Callback(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit7 as text
%        str2double(get(hObject,'String')) returns contents of edit7 as a double


% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit8_Callback(hObject, eventdata, handles)
% hObject    handle to edit8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit8 as text
%        str2double(get(hObject,'String')) returns contents of edit8 as a double


% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.pushbutton1, 'enable', 'off');
set(handles.text20, 'String', 'Processing,...');

YYYY=str2double(get(handles.edit1, 'String'));
MM=str2double(get(handles.edit2, 'String'));
DD=str2double(get(handles.edit3, 'String'));
hh=str2double(get(handles.edit4, 'String'));
mm=str2double(get(handles.edit5, 'String'));
ss=str2double(get(handles.edit6, 'String'));
long=str2double(get(handles.edit7, 'String'));
lat=str2double(get(handles.edit8, 'String'));
maxmag=str2double(get(handles.edit10, 'String'));
UTkey=get(handles.popupmenu1, 'Value');
if UTkey<14
    UTdiff=UTkey-1;
else 
    UTdiff=(UTkey-13)*-1;
end

if YYYY<2000 || isnan(YYYY)==1  || isreal(YYYY)==0
    errordlg('You have entered an invalid Year!, Year must be a number from 2000 and above','Bad Input','modal');
    set(handles.text20, 'String', '');
    set(handles.pushbutton1, 'enable', 'on');
    return
end
if MM<1 || MM>12 || isnan(MM)==1 || isreal(MM)==0
    errordlg('You have entered an invalid Month!, Month must be a number between 1 and 12 inclusive','Bad Input','modal');
    set(handles.text20, 'String', '');
    set(handles.pushbutton1, 'enable', 'on');
    return
end
if (DD<1 || DD>31 || isnan(DD)==1 || isreal(DD)==0) && ismember(MM, [1,3,5,7,8,10,12])==1
    errordlg('You have entered an invalid Day of Month!, This Month does not have the number of days you entered','Bad Input','modal');
    set(handles.text20, 'String', '');
    set(handles.pushbutton1, 'enable', 'on');
    return
end
if (DD<1 || DD>30 || isnan(DD)==1 || isreal(DD)==0) && ismember(MM, [4,6,9,11])==1
    errordlg('You have entered an invalid Day of Month!, This Month does not have the number of days you entered','Bad Input','modal');
    set(handles.text20, 'String', '');
    set(handles.pushbutton1, 'enable', 'on');
    return
end
if (DD<1 || DD>28 || isnan(DD)==1 || isreal(DD)==0) && MM==2 && mod(YYYY,4)~=0 
    errordlg('You have entered an invalid Day of Month!, This Month does not have the number of days you entered','Bad Input','modal');
    set(handles.text20, 'String', '');
    set(handles.pushbutton1, 'enable', 'on');
    return
end
if (DD<1 || DD>29 || isnan(DD)==1 || isreal(DD)==0) && MM==2 && mod(YYYY,4)==0 
    errordlg('You have entered an invalid Day of Month!, This Month does not have the number of days you entered','Bad Input','modal');
    set(handles.text20, 'String', '');
    set(handles.pushbutton1, 'enable', 'on');
    return
end
if hh<0 || hh>24 || isnan(hh)==1 || isreal(hh)==0
    errordlg('You have entered an invalid hour!, hour must be a number from 0 to 24','Bad Input','modal');
    set(handles.text20, 'String', '');
    set(handles.pushbutton1, 'enable', 'on');
    return
end
if mm<0 || mm>60 || isnan(mm)==1 || isreal(mm)==0
    errordlg('You have entered an invalid minute!, minute must be a number from 0 to 60','Bad Input','modal');
    set(handles.text20, 'String', '');
    set(handles.pushbutton1, 'enable', 'on');
    return
end
if ss<0 || ss>60 || isnan(ss)==1 || isreal(ss)==0
    errordlg('You have entered an invalid second!, second must be a number from 0 to 60','Bad Input','modal');
    set(handles.text20, 'String', '');
    set(handles.pushbutton1, 'enable', 'on');
    return
end
if long<-180 || long>180 || isnan(long)==1 || isreal(long)==0
    errordlg('You have entered an invalid longitude!, longitude must be a number between -180 and 180 inclusive','Bad Input','modal');
    set(handles.text20, 'String', '');
    set(handles.pushbutton1, 'enable', 'on');
    return
end
if lat<-90 || lat>90 || isnan(lat)==1 || isreal(lat)==0
    errordlg('You have entered an invalid latitude!, latitude must be a number between -90 and 90 inclusive','Bad Input','modal');
    set(handles.text20, 'String', '');
    set(handles.pushbutton1, 'enable', 'on');
    return
end
if isnan(maxmag)==1 || isreal(maxmag)==0
    errordlg('You have entered an invalid star magnitude!, star magnitude must be a real number','Bad Input','modal');
    set(handles.text20, 'String', '');
    set(handles.pushbutton1, 'enable', 'on');
    return
end


%-----------------------------------------------------------------
% GREENWICH MEAN SIDEREAL TIME
%-----------------------------------------------------------------
dfrac=(hh+mm/60+ss/3600)/24;
dwhole =367*YYYY-fix(7*(YYYY+fix((MM+9)/12))/4)+fix(275*MM/9)+DD-730531.5;
d=dwhole+dfrac;  %no. of days elapsed since J2000.0
dd=d-UTdiff/24;  %no of UT days elapsed since UT J2000.0
T=dd/36525;  %fraction of epoch/century time elapsed

% Meeus formula 11.4 for mean sidereal time at zero longitude (Greenwich Mean Sidereal Time)
GMST=280.46061837+(360.98564736629*dd)+(0.000387933*T^2)-(T^3/38710000); 
while GMST>360
    GMST=GMST-360;
end
while GMST<0
    GMST=GMST+360;
end

%------------------------------------------------------------------
% LOCAL SIDEREAL TIME
%------------------------------------------------------------------
LST=GMST+long;
while LST>360
    LST=LST-360;
end
while LST<0
    LST=LST+360;
end
LST=LST/15;  %LST in hours

if maxmag<6
    fid=fopen('sao6.txt');
else
   fid=fopen('saoNAN.txt'); 
end
M=textscan(fid, '%f %f %f %f %f %f %f %f', 'headerlines', 1);
sao=M{1}; mvis=M{3}; RA=(M{5}+(M{7}*(YYYY-2000)))/15; DEC=(M{6}+(M{8}*(YYYY-2000)));

scrnsz=get(0,'ScreenSize');
figure('Position',[scrnsz(1)+scrnsz(3)*0.1 scrnsz(2)+scrnsz(4)*0.1 scrnsz(3)*0.8 scrnsz(4)*0.8]);
colordef black;
for i=1:length(sao)
    
if mvis(i)<maxmag
HA =(LST - RA(i))*15;
El = asind(sind(lat)*sind(DEC(i))+cosd(lat)*cosd(DEC(i))*cosd(HA));  %http://star-www.st-and.ac.uk/~fv/webnotes/chapter7.htm
if El>0   %star is in horizon
    if El~=90 %star not at zenith
        AZ1 = (-cosd(DEC(i))*sind(HA))/cosd(El); 
        AZ2 = (cosd(lat)*sind(DEC(i))-sind(lat)*cosd(DEC(i))*cosd(HA))/cosd(El);
        if (AZ1>=0) && (AZ2>=0) %1st Quadrant anticlockwise from North
            [xxx,yyy]=linecirc(AZ2/AZ1,0,0,0,90-El);
            scatter(min(xxx),max(yyy),((maxmag-mvis(i))*2),'*','filled','MarkerEdgeColor','white', 'MarkerFaceColor', 'white'); hold on;                       
        elseif (AZ1>=0) && AZ2<0 %2nd Quadrant anticlockwise from North
            [xxx,yyy]=linecirc(AZ2/AZ1,0,0,0,90-El);
            scatter(min(xxx),min(yyy),((maxmag-mvis(i))*2),'*','filled','MarkerEdgeColor','white', 'MarkerFaceColor', 'white'); hold on;
        elseif AZ1<0 && (AZ2>=0) %4th Quadrant anticlockwise from North
            [xxx,yyy]=linecirc(AZ2/AZ1,0,0,0,90-El);
            scatter(max(xxx),max(yyy),((maxmag-mvis(i))*2),'*','filled','MarkerEdgeColor','white', 'MarkerFaceColor', 'white'); hold on;
        elseif AZ1<0 && AZ2<0 %3rd Quadrant anticlockwise from North
            [xxx,yyy]=linecirc(AZ2/AZ1,0,0,0,90-El);
            scatter(max(xxx),min(yyy),((maxmag-mvis(i))*2),'*','filled','MarkerEdgeColor','white', 'MarkerFaceColor', 'white'); hold on;
        end
    elseif El==90 %star at zenith
        scatter(0,0,((maxmag-mvis(i))*2),'*','filled','MarkerEdgeColor','white', 'MarkerFaceColor', 'white'); hold on;
    end
end
end
end
fxn=['x^2+y^2-8100']; ezplot(fxn,[-90,90]);  %draw outer circle
title(['Sky Map for Longitude ' num2str(long) ', Latitude ' num2str(lat) ', ' num2str(YYYY) '-' num2str(MM) '-' num2str(DD) ', ' num2str(hh) ':' num2str(mm) ':' num2str(ss) ' LT']); ylabel(''); xlabel(''); axis equal tight;
fclose all;

set(handles.text20, 'String', '');
set(handles.pushbutton1, 'enable', 'on');


function edit10_Callback(hObject, eventdata, handles)
% hObject    handle to edit10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit10 as text
%        str2double(get(hObject,'String')) returns contents of edit10 as a double


% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

Contact us