Page 1 of 1

ArasBeam.m: ARASBeAm Be stars list for PRISM

Posted: Fri Sep 09, 2016 8:56 pm
by Olivier Thizy
Hello,


this is a small MAtLab script that download the ARASBeAm daily file with Be stars and their priority, then it creates an "Object to observe" list for PRISM. May be useful if you use MatLab & PRISM and want to observe Be stars... :-)

Code: Select all

% ARASBeAm.m
%
% Query ARASBeAm Robot file and part it into PRISM v10 format
%
% v1.0 / 20160909 - first published
%
% Tested with MatLab2016a
% (c) Olivier Thizy
%

clear all;

% Get Robot file from ARASBeAm web server
URL = sprintf('http://arasbeam.free.fr/robot/ObsC2A.txt');
options = weboptions('Timeout',10);
Str = webread(URL);

CR = sprintf('\n'); % Carriage Return / each line is separated by a CR character...
LineEnd = strfind(Str,CR); % Find each end of line

% Parse data from URL content
for jj = 2:(size(LineEnd,2)-1) % Skip the first two lines...
    Name{jj-1} = strtrim(Str((LineEnd(jj)+1):((LineEnd(jj)+15))));
    HD{jj-1} =  strtrim(Str((LineEnd(jj)+16):((LineEnd(jj)+23))));
    RA{jj-1} =  strtrim(Str((LineEnd(jj)+24):((LineEnd(jj)+37))));
    Dec{jj-1} =  strtrim(Str((LineEnd(jj)+38):((LineEnd(jj)+51))));
    Mag{jj-1} =  strtrim(Str((LineEnd(jj)+52):((LineEnd(jj)+59))));
    ObsDate{jj-1} =  strtrim(Str((LineEnd(jj)+60):((LineEnd(jj)+70))));
    ObsTime{jj-1} =  strtrim(Str((LineEnd(jj)+71):((LineEnd(jj)+81))));
    Prio{jj-1} =  strtrim(Str((LineEnd(jj)+82):((LineEnd(jj)+82))));
    Freq{jj-1} =  str2num(strtrim(Str((LineEnd(jj)+90):((LineEnd(jj+1))))));
end

% Open the 'LST' txt file to write in
FileName= sprintf('%s_BeSS.lst',datestr(now(),'yyyymmdd'));
FileID=fopen(FileName, 'wt');

% Write each line
NbStars = size(Name,2);
EndOfLine = sprintf('\n');
for jj = 1:NbStars % Skip the first two lines...
    fprintf(FileID,'"P%s %s"  %sh%sm%s0s  %s°%s''%s0''''  %s  FALSE  "prio: %s (%d%%: %dd/%dd)"%s',Prio{jj},Name{jj},RA{jj}(2:3),RA{jj}(5:6),RA{jj}(8:11),Dec{jj}(1:3),Dec{jj}(5:6),Dec{jj}(8:11),Mag{jj},Prio{jj},int16((now()-datenum(ObsDate{jj}))*100.0/Freq{jj}),int16((now()-datenum(ObsDate{jj}))),Freq{jj},EndOfLine);
end

% Close file
fclose(FileID);

% That's all folks!

Cordialement,
Olivier Thizy

Re: ArasBeam.m: ARASBeAm Be stars list for PRISM

Posted: Mon Sep 12, 2016 1:04 pm
by Olivier Thizy
Hello,


there seems to be some trouble with the ObsC2A.txt file from ARASBeAm on priority; I modified the script to calculate priority based on dates and not taken from the file itself. I also removed the stars with Dec < -30°.

Here is the v1.1 code I now use:

Code: Select all

% ARASBeAm.m
%
% Query ARASBeAm Robot file and part it into PRISM v10 format
%
% v1.0 / 20160909 - first published
% v1.1 / 20160912 - priority calculated based on dates and not from ObsC2A.txt
%                 - V2136 Cyg negative Obs_Period taken into account
%                 - only stars with Dec > -30 kept
%
% Tested with MatLab2016a
% (c) Olivier Thizy
%

clear all;

% Get Robot file from ARASBeAm web server
URL = sprintf('http://arasbeam.free.fr/robot/ObsC2A.txt');
options = weboptions('Timeout',10);
Str = webread(URL);

CR = sprintf('\n'); % Carriage Return / each line is separated by a CR character...
LineEnd = strfind(Str,CR); % Find each end of line

index = 1;
% Parse data from URL content
for jj = 2:(size(LineEnd,2)-1) % Skip the first two lines...
    Dec_deg = str2num(strtrim(Str((LineEnd(jj)+38):((LineEnd(jj)+40)))));
    if Dec_deg > -30
        Name{index} = strtrim(Str((LineEnd(jj)+1):((LineEnd(jj)+15))));
        HD{index} =  strtrim(Str((LineEnd(jj)+16):((LineEnd(jj)+23))));
        RA{index} =  strtrim(Str((LineEnd(jj)+24):((LineEnd(jj)+37))));
        Dec{index} =  strtrim(Str((LineEnd(jj)+38):((LineEnd(jj)+51))));
        Mag{index} =  strtrim(Str((LineEnd(jj)+52):((LineEnd(jj)+59))));
        ObsDate{index} =  strtrim(Str((LineEnd(jj)+60):((LineEnd(jj)+70))));
        ObsTime{index} =  strtrim(Str((LineEnd(jj)+71):((LineEnd(jj)+81))));
        % Prio{index} =  strtrim(Str((LineEnd(jj)+82):((LineEnd(jj)+82))));
        Freq{index} =  str2num(strtrim(Str((LineEnd(jj)+90):((LineEnd(jj+1))))));
        if Freq{index} < 0 % Pb with V2136 Cyg negative Obs_Period !
            Freq{index} = - Freq{index};
        end
        Ratio = int16((now()-datenum(ObsDate{index}))*100.0/Freq{index});
        if Ratio < 70
            Prio{index} = 3;
        elseif Ratio > 100
            Prio{index} = 1;
        else
            Prio{index} = 2;
        end
        UnsortedKey(index,1) = index;
        UnsortedKey(index,2) = Ratio;
        index = index + 1;
    end
end

% Sort data by decreasing percentage (ie: priority)
SortedKey = sortrows(UnsortedKey,[-2]);

% Open the 'LST' txt file to write in
FileName= sprintf('%s_BeSS.lst',datestr(now(),'yyyymmdd'));
FileID=fopen(FileName, 'wt');

% Write each line
NbStars = size(Name,2);
EndOfLine = sprintf('\n');
for index = 1:NbStars % Skip the first two lines...
    jj = SortedKey(index,1);
    fprintf(FileID,'"P%d %s"  %sh%sm%s0s  %s°%s''%s0''''  %s  FALSE  "prio: %d (%d%%: %dd/%dd)"%s',Prio{jj},Name{jj},RA{jj}(2:3),RA{jj}(5:6),RA{jj}(8:11),Dec{jj}(1:3),Dec{jj}(5:6),Dec{jj}(8:11),Mag{jj},Prio{jj},int16((now()-datenum(ObsDate{jj}))*100.0/Freq{jj}),int16((now()-datenum(ObsDate{jj}))),Freq{jj},EndOfLine);
end

% Close file
fclose(FileID);

% That's all folks!

Cordialement,
Olivier

Re: ArasBeam.m: ARASBeAm Be stars list for PRISM

Posted: Sun Oct 30, 2016 6:02 pm
by Vincent Lecocq
adopté !

merci !

Re: ArasBeam.m: ARASBeAm Be stars list for PRISM

Posted: Fri Jul 03, 2020 8:09 pm
by Kevin Gurney
Hi

Inspired by this thread, I have coded up a similar converter in Python. It is less ambitious than the original, in that you have to first copy and paste from the original web page
http://arasbeam.free.fr/spip.php?page=b ... t2&lang=en
into a text file, but this isn't too arduous.. :)

Kevin

Code: Select all

# Convert a text file 'scraped' from the ArasBeAm Be target site to Prism obs lists.
# Just copy and paste over a selection - possibly everything if needed -
# but could be more limited.
# The text file has to be named 'bess.txt' and this is converted to three .lst files
# One for each priority. I have guessed the citerion for the 'red/yellow/green
# categories so they might need to be finessed in the variable 'date_margin'
# which currently assumes 80% time lapse between observations to be on the 'yellow'
# list
#
# Kevin Gurney July 2020
#


from dateutil.parser import parse
from dateutil.relativedelta import *
from datetime import *;
import calendar

min_mag = input('give minimum magnitude ')
min_mag = float(min_mag)

now = datetime.now()

sep = ' '
date_margin = 0.8

len_time_field = 8 # some records don't have a last obs date and time...
dummy_date = "2018-01-01" # ... so make sure they are on hot list
dummy_time = "00:00:01"
time_field = 1

fpw1 = open('bess1.lst', 'w')
fpw2 = open('bess2.lst', 'w')
fpw3 = open('bess3.lst', 'w')

with open('bess.txt', 'r') as fp:
    line = fp.readline()
    while line:
        fields = line.split()
        
        fields.reverse()
        if len(fields[time_field]) < len_time_field:
            stublist = [fields[0], dummy_time, dummy_date]
            newf = stublist + fields[1:]
            fields = newf
        
        name_fields = fields[15:]
        name_fields.reverse()
        name = sep.join(name_fields)

        last_obs_str = fields[2]
        last_obs = parse(last_obs_str)
        
        delta_t = now - last_obs
        delta_t_days = delta_t.days

        interval_str = fields[0];
        interval = int(interval_str)
        if delta_t_days > interval:
            urgency = "1"
        elif delta_t_days > interval * date_margin:
            urgency = "2"
        else:
            urgency = "3"
            
            
        HD = fields[14]
        if not(HD == '0'):
            HD_number = 'HD ' + HD
        else:
            HD_number = 'HD none'

        Comment = HD_number        
        RAhr = fields[13]
        RAhr = RAhr[1:]  # strip the + sign
        RAmin = fields[12]
        RAsec = fields[11]

        RAsec = "{:05.2f}".format(float(RAsec)) # need 2 dec places and possibly leading zeros
        DECdeg = fields[10]
        DECmin = fields[9]
        DECsec = fields[8]
        
        RA = RAhr + 'h' + RAmin + 'm' + RAsec + 's'
        DEC = DECdeg + '°' + DECmin + '\'' + DECsec + '\'\''

        mag = fields[7]
        fmag = float(mag)
        if fmag < min_mag:
            ons_line = '\"' + name + '\"  ' + RA + '  ' + DEC + '  ' + mag + '  FALSE ' + urgency + '  ' + '\"' + HD_number + '\"\n'
            if urgency == "1":
                fpw1.write(ons_line)
            elif urgency == "2":
                fpw2.write(ons_line)
            else:
                fpw3.write(ons_line)
                
        line = fp.readline()
              

fpw1.close()
fpw2.close()
fpw3.close()
    
    


Re: ArasBeam.m: ARASBeAm Be stars list for PRISM

Posted: Fri Jul 03, 2020 10:29 pm
by Kevin Gurney
Hagh! Just discovered its now embedded in the 'import' menu in Prism...
Well, I enjoyed the coding :)

Kevin