folder_no] + file_name_list_current[file] # Run ADR reader for the current folder done_or_not, DAT_file_name, DAT_file_list = ADR_file_reader( file_name_list_current, result_path, MaxNim, RFImeanConst, Vmin, Vmax, VminNorm, VmaxNorm, VminCorrMag, VmaxCorrMag, customDPI, colormap, CorrelationProcess, 0, 1, 1, 1, 1, 0, DynSpecSaveInitial, DynSpecSaveCleaned, CorrSpecSaveInitial, CorrSpecSaveCleaned, SpecterFileSaveSwitch, ImmediateSpNo) print('\n * DAT reader analyzes file:', DAT_file_name, ', of types:', DAT_file_list, '\n') DAT_result_path = list_of_folder_names[folder_no].replace('/', '_').replace( ':', '')[:-1] # Run DAT reader for the resuls of current folder done_or_not = DAT_file_reader(path_to_results, DAT_file_name, DAT_file_list, DAT_result_path, averOrMin, 0, 0, VminMan, VmaxMan, VminNormMan, VmaxNormMan, RFImeanConst, customDPI, colormap, 0, 0, 0, AmplitudeReIm, 0, 0, '', '', 0, 0, [], 0) endTime = time.time() # Time of calculations print('\n\n\n The program execution lasted for ', round((endTime - startTime), 2), 'seconds (', round((endTime - startTime) / 60, 2), 'min. ) \n') print(' *** Program ', Software_name, ' has finished! *** \n\n\n')
' Time is chosen correctly but adjusted for 1 day ahead! \n') else: print( ' ERROR! Culmination time is calculated chosen out of file limits!!! \n\n' ) sys.exit(' Program stopped! \n\n') # DAT_result_path = 'DAT_Results_' + data_files_name_list[file_no] if AutoStartStop == 1: dateTimeStart = str(start_time)[0:19] dateTimeStop = str(end_time)[0:19] done_or_not = DAT_file_reader( path_to_data, data_files_name_list[file_no], [type_of_data], data_files_name_list[file_no] + '_' + source, averOrMin, StartStopSwitch, SpecFreqRange, VminMan, VmaxMan, VminNormMan, VmaxNormMan, RFImeanConst, customDPI, colormap, ChannelSaveTXT, ChannelSavePNG, ListOrAllFreq, AmplitudeReIm, freqStart, freqStop, dateTimeStart, dateTimeStop, freqStartTXT, freqStopTXT, freqList, 0) # See script_DAT_multifile_reader.py for correction! # Saving TXT file with parameters from file header path = path_to_data + 'DAT_Results_' + data_files_name_list[ file_no] + '_' + source + '/' TXT_file = open( path + data_files_name_list[file_no] + '_' + source + '_header.info', "w") TXT_file.write(' Observatory: ' + df_obs_place + '\n') TXT_file.write(' Receiver: ' + df_system_name + '\n') TXT_file.write(' Initial filename: ' + df_filename + '\n') TXT_file.write(' Description: ' + df_description + '\n') TXT_file.write(' Source for processing: ' + source + '\n')
start_time = culm_time_3C405[i] - TimeDelta(3600, format = 'sec') end_time = culm_time_3C405[i] + TimeDelta(3600, format = 'sec') dateTimeStart = str(start_time)[0:19] dateTimeStop = str(end_time)[0:19] [df_filename, df_filesize, df_system_name, df_obs_place, df_description, CLCfrq, df_creation_timeUTC, ReceiverMode, Mode, sumDifMode, NAvr, TimeRes, fmin, fmax, df, frequency, FFTsize, SLine, Width, BlockSize] = FileHeaderReaderADR(path_to_data + dat_files_list[0], 0, 0) result_folder = data_files_name_list[0]+"_"+str(i+1)+'_of_'+str(len(culm_time_3C405))+'_'+source done_or_not = DAT_file_reader(path_to_data, data_files_name_list[0], typesOfData, result_folder, averOrMin, StartStopSwitch, SpecFreqRange, VminMan, VmaxMan, VminNormMan, VmaxNormMan, RFImeanConst, customDPI, colormap, ChannelSaveTXT, ChannelSavePNG, ListOrAllFreq, AmplitudeReIm_GURT, freqStart, freqStop, dateTimeStart, dateTimeStop, freqStartTXT, freqStopTXT, freqList_GURT, 0) # Saving TXT file with parameters from file header path = path_to_data + 'DAT_Results_' + result_folder + '/' TXT_file = open(path + data_files_name_list[0]+'_'+source + '_header.info', "w") TXT_file.write(' Observatory: ' + df_obs_place + '\n') TXT_file.write(' Receiver: ' + df_system_name + '\n') TXT_file.write(' Initial filename: ' + df_filename + '\n') TXT_file.write(' Description: ' + df_description + '\n') TXT_file.write(' Source for processing: ' + source + '\n') TXT_file.write(' Culmination time: ' + str(culm_time_3C405[i]) + '\n') TXT_file.write(' Receiver mode: ' + ReceiverMode + '\n') TXT_file.write(' Time resolution: ' + str(np.round(TimeRes, 6)) + ' s \n') TXT_file.write(' Frequency range: ' + str(fmin) + ' - ' + str(fmax)+ ' MHz \n')
ok, DAT_file_name, DAT_file_list = ADR_file_reader( file_name_list_current, result_path, MaxNim, RFImeanConst, Vmin, Vmax, VminNorm, VmaxNorm, VminCorrMag, VmaxCorrMag, customDPI, colormap, CorrelationProcess, 0, 1, 1, 1, 1, 0, DynSpecSaveInitial, DynSpecSaveCleaned, CorrSpecSaveInitial, CorrSpecSaveCleaned, SpecterFileSaveSwitch, ImmediateSpNo, 0) print('\n * DAT reader analyzes file:', DAT_file_name, ', of types:', DAT_file_list, '\n') result_path = dir_data_on_server + data_directory_name + '/' # Run DAT reader for the results of current folder ok = DAT_file_reader('', DAT_file_name, DAT_file_list, result_path, data_directory_name, averOrMin, 0, 0, VminMan, VmaxMan, VminNormMan, VmaxNormMan, RFImeanConst, customDPI, colormap, 0, 0, 0, AmplitudeReIm, 0, 0, '', '', 0, 0, [], 0) # Sending message to Telegram message = 'Data of '+ data_directory_name.replace('_',' ') + ' observations ('+ parameters_dict["receiver_name"].replace('_',' ') \ +' receiver, IP: ' + receiver_ip + ') were copied and processed.' try: test = telegram_bot_sendtext(telegram_chat_id, message) except: pass print('\n\n *** Program ', Software_name, ' has finished! *** \n\n\n') ''' *** Possible workflow ***
results_files_list = jds_wf_simple_reader(directory, no_of_spectra_to_average, 0, 0, 8, 'Greys', 300, 1, 0, 1) print('\n\n * Making dynamic spectra of the initial data... \n\n') typesOfData = ['chA'] if len(results_files_list) > 1 and process_channel_b: typesOfData.append('chB') else: results_files_list = [results_files_list[0]] result_folder_name = directory.split('/')[-2] + '_initial' ok = DAT_file_reader('', results_files_list[0][:-13], typesOfData, '', result_folder_name, 0, 0, 0, -120, -10, 0, 6, 6, 300, 'jet', 0, 0, 0, 20 * 10**(-12), 16.5, 33.0, '', '', 16.5, 33.0, [], 0) # # # results_files_list = ['E080219_200543.jds_Data_chA.dat'] # # print('\n\n * Dispersion delay removing... \n\n') dedispersed_data_file_list = [] for i in range(len(results_files_list)): dedispersed_data_file_name = pulsar_incoherent_dedispersion( '', results_files_list[i], pulsar_name, 512, -0.15, 0.55, 0, 0, 0, 1, 10, 2.8, 0, 0.0, 16.5, 1, 1, 300, 'Greys') dedispersed_data_file_list.append(dedispersed_data_file_name)
print(' * Number of datasets (time line files) found: ', len(timeline_file_name_list), '\n') # Loop by data types selected by user for file_no in range(len(data_files_name_list)): print(' Dataset No: ', file_no + 1, ' of ', len(timeline_file_name_list), '\n') dat_types_list = [] for type_of_data in range(len(data_types)): name = data_files_name_list[file_no] + '_Data_' + data_types[ type_of_data] + '.dat' if os.path.isfile(path_to_data + name): dat_types_list.append(data_types[type_of_data]) result_folder_name = data_files_name_list[file_no] done_or_not = DAT_file_reader( path_to_data, data_files_name_list[file_no], dat_types_list, '', result_folder_name, aver_or_min, start_stop_switch, spec_freq_range, v_min_man, v_max_man, v_min_norm_man, v_max_norm_man, rfi_mean_const, custom_dpi, colormap, channel_save_txt, channel_save_png, list_or_all_freqs, amplitude_re_im, freq_start, freq_stop, date_time_start, date_time_stop, freq_start_txt, freq_stop_txt, freq_list, 0) stop_time = time.time() print('\n\n\n The program execution lasted for ', round((stop_time - start_time), 2), 'seconds (', round((stop_time - start_time) / 60, 2), 'min. ) \n') print('\n *** Program ', software_name, ' has finished! *** \n\n\n')
def copy_and_process_adr(copy_data, process_data, dir_data_on_server, data_directory_name, parameters_dict, telegram_chat_id, receiver_ip, MaxNim, RFImeanConst, Vmin, Vmax, VminNorm, VmaxNorm, VminCorrMag, VmaxCorrMag, customDPI, colormap, CorrelationProcess, DynSpecSaveInitial, DynSpecSaveCleaned, CorrSpecSaveInitial, CorrSpecSaveCleaned, SpecterFileSaveSwitch, ImmediateSpNo, averOrMin, VminMan, VmaxMan, VminNormMan, VmaxNormMan, AmplitudeReIm): time.sleep(10) if copy_data > 0: ok = f_copy_data_from_adr(receiver_ip, data_directory_name, dir_data_on_server, 0) if process_data > 0: time.sleep(5) # Processing data with ADR reader and DAT reader # Find all files in folder once more: # file_name_list_current = find_and_check_files_in_current_folder(dir_data_on_server+data_directory_name+'/','.adr') file_name_list_current = find_files_only_in_current_folder(dir_data_on_server+data_directory_name+'/', '.adr', 0) file_name_list_current.sort() print('\n\n * ADR reader analyses data... \n') # Making a name of folder for storing the result figures and txt files result_path = dir_data_on_server + data_directory_name + '/' + 'ADR_Results_' + data_directory_name for file in range(len(file_name_list_current)): file_name_list_current[file] = dir_data_on_server + data_directory_name + '/' + file_name_list_current[file] # Run ADR reader for the current folder ok, DAT_file_name, DAT_file_list = ADR_file_reader(file_name_list_current, result_path, MaxNim, RFImeanConst, Vmin, Vmax, VminNorm, VmaxNorm, VminCorrMag, VmaxCorrMag, customDPI, colormap, CorrelationProcess, 0, 1, 1, 1, 1, 0, DynSpecSaveInitial, DynSpecSaveCleaned, CorrSpecSaveInitial, CorrSpecSaveCleaned, SpecterFileSaveSwitch, ImmediateSpNo, 0) print('\n * DAT reader analyzes file:', DAT_file_name, ', of types:', DAT_file_list, '\n') result_path = dir_data_on_server + data_directory_name + '/' # Run DAT reader for the results of current folder ok = DAT_file_reader('', DAT_file_name, DAT_file_list, result_path, data_directory_name, averOrMin, 0, 0, VminMan, VmaxMan, VminNormMan, VmaxNormMan, RFImeanConst, customDPI, colormap, 0, 0, 0, AmplitudeReIm, 0, 0, '', '', 0, 0, [], 0) message = '' if process_data > 0: message = 'Data of ' + data_directory_name.replace('_', ' ') + ' observations (' + parameters_dict[ "receiver_name"].replace('_', ' ') + ' receiver, IP: ' + receiver_ip + ') were copied and processed.' else: if copy_data > 0: message = 'Data of ' + data_directory_name.replace('_', ' ') + ' observations (' + \ parameters_dict["receiver_name"].replace('_', ' ') + ' receiver, IP: ' + receiver_ip + ') were copied.' print('\n * ' + message) # Sending message to Telegram try: test = telegram_bot_sendtext(telegram_chat_id, message) except: pass return 1