def writeTargetList(fNameIn, fNameOut, raString='CS_RAJ2000', decString='CS_DECJ2000'): all = readCSV(fNameIn) print('writeTargetList: read ', len(all), ' lines') with open(fNameOut, 'w') as f: for lineIn in all: lineOut = lineIn['Name'].replace(' ', '_').replace( '"', '' ) + ' ' + lineIn[raString] + ' ' + lineIn[decString] + ' J2000\n' f.write(lineOut)
from findTargets import readCSV #fNameIn = '/Users/azuri/daten/uni/HKU/observing/targets_SSO_priority_good_new.csv' fNameIn = '/Users/azuri/daten/uni/HKU/observing/targets_SSO_new_noDiamGiven_good.csv' #fNameIn = '/Users/azuri/daten/uni/HKU/observing/targets_SAAO_good.csv' fNameOut = fNameIn[0:fNameIn.rfind('.')] + '_RA_DEC.dat' lines = readCSV(fNameIn) outList = [] with open(fNameOut, 'w') as f: for line in lines: f.write(line['RAJ2000'] + ' ' + line['DECJ2000'] + '\n')
def createTargetLists(): allSiteNames = EarthLocation.get_site_names() observatoryName = "Roque de los Muchachos" gtcObs = Observer.at_site( observatoryName) #, timezone='Eastern Standard Time') print('dir(gtcObs) = ', dir(gtcObs)) print('gtcObs.location = ', gtcObs.location) # gtc = EarthLocation(lat=dmsToDeg()*u.deg, lon=149.0685*u.deg, height=1165*u.m) gtc_utcoffset = 1 * u.hour # Australian Eastern Standard Time minimumAltitude = 30. midnight = midnightTime - gtc_utcoffset #print('astronomical twilight as Observatory: %s - %s' % (obs.twilight_evening_astronomical(midnight), obs.twilight_morning_astronomical(midnight))) observationStartTime = gtcObs.twilight_evening_astronomical( midnight) #Time('2019-9-5 19:10:00') - utcoffset observationEndTime = gtcObs.twilight_morning_astronomical( midnight) #Time('2019-9-6 4:55:00') - utcoffset observationStartTime.format = 'iso' observationEndTime.format = 'iso' catLines = readCSV(allPossibleTargets) targetsWithCS = findCSPNe(catLines) time = observationStartTime times = [time] fullHours = [] while time < observationEndTime: time += 1 * u.minute # print('time = ',time) times.append(time) # print('time = ',time) # print('type(time) = ',type(time)) # print('dir(time) = ',dir(time)) # print('type(time.to_datetime()) = ',type(time.to_datetime())) # print('dir(time.to_datetime()) = ',dir(time.to_datetime())) if time.to_datetime().strftime("%M") == '00': # print('full hour found at ',time) fullHours.append(time) goodTargets = findGoodTargets(targetsWithCS, gtcObs.location, raString='CS_DRAJ2000', decString='CS_DDECJ2000') writeCSV(goodTargets, targetListOut, 'DRAJ2000') allGoodTargets = [] allGoodTargetIDs = [] for time in fullHours: visibleAt = findTargetsVisibleAt(goodTargets, time, gtcObs.location, gtc_utcoffset, minimumAltitude) localTime = time + gtc_utcoffset writeCSV( visibleAt, targetListOut[:-4] + '_visible_at_' + date + '_' + localTime.strftime("%H-%M") + '.csv', 'DRAJ2000') # print('visibleAt[0] = ',visibleAt[0]) ra = float(visibleAt[0]['CS_DRAJ2000']) dec = float(visibleAt[0]['CS_DDECJ2000']) targetCoord = SkyCoord(ra=ra * u.deg, dec=dec * u.deg, frame='icrs') # print('ra, dec = ',ra,dec) # plot_target(targetCoord, gtcObs.location, observatoryName, gtc_utcoffset, date, False) print('ra, dec = ', ra, dec) for line in visibleAt: if line['idPNMain'] not in allGoodTargetIDs: allGoodTargetIDs.append(line['idPNMain']) allGoodTargets.append(line) writeCSV(allGoodTargets, targetListOut[:-4] + '_visible_at_' + date + '.csv')
# print('visibleAt[0] = ',visibleAt[0]) ra = float(visibleAt[0]['CS_DRAJ2000']) dec = float(visibleAt[0]['CS_DDECJ2000']) targetCoord = SkyCoord(ra=ra * u.deg, dec=dec * u.deg, frame='icrs') # print('ra, dec = ',ra,dec) # plot_target(targetCoord, gtcObs.location, observatoryName, gtc_utcoffset, date, False) print('ra, dec = ', ra, dec) for line in visibleAt: if line['idPNMain'] not in allGoodTargetIDs: allGoodTargetIDs.append(line['idPNMain']) allGoodTargets.append(line) writeCSV(allGoodTargets, targetListOut[:-4] + '_visible_at_' + date + '.csv') if __name__ == '__main__': #createTargetLists() visibilityLists = '/Users/azuri/daten/uni/HKU/HASH/CSPN_GTC_targets/allTruePNe_withCS_visible.list' with open(visibilityLists, 'r') as vf: lists = [f.rstrip() for f in vf.readlines()] allCSPN = [] allCSPNIDs = [] for list in lists: csv = readCSV(list) for line in csv: if line['idPNMain'] not in allCSPNIDs: allCSPNIDs.append(line['idPNMain']) allCSPN.append(line) writeCSV(allCSPN, visibilityLists[:-4] + 'csv')
from findTargets import readCSV, writeCSV fileA = '/Users/azuri/daten/uni/HKU/observing/targets_SSO_priority_new_good.csv' fileB = '/Users/azuri/daten/uni/HKU/observing/targets_SSO_priority_good.csv' fileNameOut = '/Users/azuri/daten/uni/HKU/observing/targets_SSO_priority_good_new.csv' targetsA = readCSV(fileA) targetsB = readCSV(fileB) goodTargets = [] for lineA in targetsA: for lineB in targetsB: if lineA['idPNMain'] == lineB['idPNMain']: goodTargets.append(lineA) writeCSV(goodTargets, fileNameOut, 'DRAJ2000')