La Isla Bonita

In April I managed to persuade my supervisors that I needed to return to La Palma to get training on how to use ULTRACAM (the big brother of ULTRASPEC). The ultimate aim, I think, is for me to become one of the core team members who can go out and use it as an ‘expert’, without the need of one of the other team members to be present. This is quite exciting, as there is talk of the instrument being shipped to Chile for use at the NTT next time round, rather than at the WHT where it is currently. Anyway, I recently spent a week on the lovely Isla Bonita, which I still consider to be my third home.

I’ll save the best bits for the middle, and start with the worst part of the trip. This was undoubtedly the travel to and from the island. Being one of the smaller, less populated, and less touristic islands, La Palma has very few direct flights from outside of Spain. Even though I wasn’t paying for it myself, I was still trying to spend as little of my travel budget as possible, so I’d booked Ryanair (world’s worst airline) flights to Gran Canaria, and connecting inter-island flights with Binter Canarias (world’s best airline). Sadly, all of my flights on the way out were delayed (some by up to an hour), which added an unwanted level of stress to the already stressful event. Travelling with Ryanair isn’t fun at the best of times, but when the flight is an hour late, the staff are keen to get everyone sat down even more swiftly than usual. This, coupled with everyone else on the flight’s absolutely and uncompromising need to sit with their children/partner/friends makes for a bad start. To be fair though, the rest of the flight was bearable, and the return trip wasn’t too bad at all. I even got a breakfast donut on the first Binter flight on the way home – win!

My first evening back on La Palma was spent in true traditional style – eating pizza at Mamma Mia’s pizzeria. And boy had I missed those pizzas! I’d happily eat there every night if it was so unhealthy… oh yeah, and 2500km away.  Anyway, it was really great to catch up with old friends on the island, and the following day I was up early to go diving.

Having not been underwater in 9 months, I was a little nervous about my abilities. Because of this, I turned down the opportunity to join the divers heading for the small, shallow cave just south of Los Cancajos, and instead went through El Cañon with Ricardo. I really shouldn’t have worried though, as I felt right at home within seconds of being in the water. So, whilst I was perhaps a little disappointed to not be exploring a cave, it was still brilliant just to be back in the warm, clear water with a good friend. Sadly I could only fit in one, shallow dive that morning, as I had to be up at the observatory in the evening, and didn’t want to risk any difficulties with decompression. Luckily though, I managed to arrange to have one more full day at sea-level after the 5 nights on the mountain, and squeezed in another two dives. These were from El Faro de Fuencaliente in the south (one to La Torreta and one to Las Cruces) and both were excellent dives. My diving spirit has definitely been rekindled, and now I can’t wait for the illusive trip to Thailand, where I hope to fit in some more warm water diving.

Looking up towards El Roque

Looking up towards El Roque

After one night’s sleep at the Residencia of the observatory, it was straight to work at 9:30am. The task for the day was to mount and test ULTRACAM, whilst learning how to mount and test ULTRACAM, and simultaneously taking photos and writing a guide on how to mount and test ULTRACAM.

CIMG7527

Working hard

This all went rather well, and the day went quickly. There were no major problems (such situations are almost unheard of in observational astronomy!), and there was even time for a shower before the ‘real’ work began.

Compulsory "check me out with this big cool science thing!" photo

Compulsory “check me out with this big cool science thing!” photo

As the sun began to set, it was time to embark on some real astronomy – searching for the secondary eclipse of a transiting exoplanet. This is when the planet passes behind its host star, which shadows any light reflected off the planet’s atmosphere. Even for faint stars and massive, very shiny planets, this change in measured light is as little as 0.1%, which is very hard to see. In the rough data reductions of the three nights of data we collected for these systems, we could see no obvious signs of an eclipse. This in itself is not entirely useless though, as it allows the team (based in Leiden, the Netherlands) to put tight constraints on just how bright/reflective the planet is, which in turn can be used to try to understand what the atmosphere of the planet is made of.

On my 5th and final night at the telescope we were observing the transits of other exoplanet candidates from the Kepler survey.  Utilising ULTRACAM’s three-colour system, Stu will be able to determine if any of the candidates are in fact grazing eclipsing binary systems, rather than transiting planets. If the transit depths are different in different colours (essentially red, green or blue), this would suggest than the system is actually an eclipsing binary system, where the two stars involved have significantly different surface colours, but their eclipse paths are not fully aligned with our line of sight. Instead, only a small fraction of the light from one of the stars is blocked, in a grazing eclipse. This would cause a small eclipse depth, as seen in exoplanet transits, without there necessarily being a planet present.

As well as doing ‘real science’ with the WHT (although I must add, I was simply watching and learning, most of the time), Stu and I also spent some time working with the pt5m. As well we faffed around with the Python coding (most of which was written by Stu anyway) that we’re now using to automatically reduce data from transient observations taken with the pt5m, and submit the results to the GAIA Science Alerts server. Of course, when you’re only observing one or two targets over the course of an entire night, and there’s 5 people on hand to keep an eye on things, there is still plenty of time to watch cartoons 😉

Observing with the pt5m (foreground) and the WHT (background) at the same time!

Observing with the pt5m (foreground) and the WHT (background) at the same time!

Observations of the decaying lightcurve of Supernova ASASSN-12ax from a number of telescopes, including the pt5m.

Observations of the decaying lightcurve of ASASSN-13ax (possible nova or supernova) from a number of telescopes, including the pt5m.

Overall I really enjoyed the return visit to La Palma, and it was great to catch up with old friends. I just wish I could have spent more time both at the observatory and at sea level! Within 24 hours of landing back in the UK I was setting up my tent at Latitude Festival for another week of hard work and baking hot sunshine. It was certainly tough moving quickly from working the night shift to working the 10-16 hour day (and night!) shifts, but it was great to be back at my favourite big festival again, and I’m already looking forward to next year.

Old favourite view from the WHT

Old favourite view from the WHT

Advertisements

London, Glastonbury and moving house

*Disclaimer: This post is completely unrelated to astronomy and my PhD*

After my exciting 3-day trip to Paris, I spent a long weekend in London before heading off to work at Glastonbury Festival. My time in London reaffirmed my new appreciation of Paris, by being comparatively colder, noisier, and more full of slow-walking pavement hoggers. Despite this, I had an excellent time catching up with friends, learning to longboard, watching Community, juggling, seeing Ben win a skate-dance competition, visiting art galleries, playing ninja and eating yummy Indian food courtesy of the man who left his cash in the ATM at Euston station. As mentioned previously, I’ve never been a big fan of London, mostly because I’m always struggling to pass *through* it with a lot of luggage. That said, the more time I spend actually living and playing in the biggest city in Europe, the more I warm to it.

Having thoroughly failed to catch up on sleep, I headed off to Glastonbury on the Monday. Arriving two days before our catering was due to start with very little of my own food was a bad idea. I spent the first evening stapling food vouchers together while my stomach growled audibly, and the second day helping to register nearly 1000 staff as they arrived on site, all the while making “I’m hungry!” signals at friends as they arrived, hoping someone would take pity on me and share some food (big thanks are owed to Phin for fetching me a fantastic falafel wrap).

On Wednesday the real work began, as our bar (Tolpuddle) was open from 11am to 2am, though we had to start at 9am to get everything ready. I had around 2 hours break throughout the entire day, because even though the bar wasn’t busy at all, I had to work out exactly what my job was, learn how to do it, and revise it to be more efficient and worker friendly. Long day, huh?

On Thursday I was lucky enough to be working the early shift (10am-8pm), but despite having the ‘evening off’ I was unable to stay awake past midnight, and subsequently didn’t catch much of the first official night of Glastonbury. Unfortunately, this pretty much set the tone for the rest of the weekend, with my shifts taking over the majority of my waking hours, and my energy levels generally too low to appreciate anything else. Finishing work at 11pm on Friday meant I was able to catch the encore of the Arctic Monkeys, and enjoyed a cheeky dance at the Guilty Pleasures disco (old favourite of Latitude festival)

Noah and the Whale in the sun

Noah and the Whale in the sun

I did also manage to have a rather excellent Saturday, catching up with several old friends, seeing a bit of Noah and the Whale, sweat-drenched dancing with the Electric Swing Circus, and enjoying an outstanding performance by Dizraeli & the Small Gods. On Sunday I succeeded in experiencing my best gig of all time, with Ben Caplan – the massively bearded, Canadian, shouty folk singer, who shook my hand and signed my album after the show. This was perhaps my first real understanding of the word ‘starstruck’.

Bearded legend, Ben Caplan shaking my hand

Bearded legend, Ben Caplan shaking my hand

As usual, closing and packing down the bar on the last night was horrific, and topping off the night with only 1 hour of sleep was a definite mistake. The journey home on Monday was unnecessarily stressful, mostly because we had the world’s most incompetent and dangerous bus driver taking us in circles around the Somerset countryside. Thankfully I did manage to dash across London, pick up my left-behind bags and catch my train home, with 5 minutes to spare. Overall I definitely enjoyed Glastonbury, although being paid for it may be a factor here. Still, I’m glad I went, and I’m quite looking forward to Latitude now.

After 12 hours sleep, I was more or less ready to return to Sheffield to move house. Somehow I’ve ended up with the smallest room in the house, which is about half the size of my last one. Having lived in a large bedroom for 7.5 out of the last 8 years, I’ve been struggling to fit all my belongings into it neatly, but it is cosy and comfortable, so I’m still excited for the year ahead. Unfortunately this was more or less the end of my working “holiday”, and I was back to mundane tasks in the office by Wednesday morning.

A little glimpse into my new bedroom

A little glimpse into my new bedroom

Now, back to astronomy stuff, I suppose. Coming up next: Observing with ULTRACAM at the WHT in La Palma.

GAIA Science Alerts Workshop – Paris

I went to my first official astronomy conference a few weeks ago, at the Insitut d’Astrophysique de Paris (IAP). I travelled with my co-supervisor, Stu, down to London and on the Eurostar too. Actually the most exciting part of the trip was couchsurfing with the lovely Judith, who lives in a top-floor apartment in the snazzy ‘Bourse’ area. You can climb up onto the roof and see the entire city from there – it’s beautiful. I genuinely had no love for any big city until we sat on the roof eating dinner and watching the sun set behind the Eiffel Tower. With a view like that, I reckon I could deal with big-city life.

Dinner on a Paris rooftop - spot the Eiffel Tower

Dinner on a Paris rooftop – spot the Eiffel Tower

Another thing about big cities which I’ve always found off-putting is the public transport system. To be fair, my opinion of this has always been based around my experiences in London, which can be summed up in three words: stressful, unreliable, expensive. This is another winner for Paris – the bus, metro and RER trains network is extensive, fast, and relatively cheap. I was genuinely impressed, and I actually look forward to the next time I have to travel across Paris.

Sunset over Paris

Sunset over Paris

The conference itself was actually a ‘workshop’. The difference being that after two days of people giving 15-30 minute presentations, we had half a day of discussion and feedback. Otherwise, as far as I can tell, it was very much a conference. Despite being perpetually exhausted, I managed to stay awake and pay attention throughout most of the talks, and really enjoyed some of them. I learnt a lot about how the European Space Agency’s (ESA) upcoming satellite GAIA will play such an important role for astronomy over the next few years, especially in the field of transients. By surveying the entire night sky many times over the mission period of 5 years, countless new and exciting variable objects will be found. Much of the discussion was focussed on how small telescopes (like pt5m) will be able to give rapid feedback about new alerts generated by the GAIA alerts team, and hopefully help them to tailor their alert software as part of the verification phase. This is super exciting and hopefully we can play a big part in it.

Paris Observatory (IAP)

Paris Observatory (IAP)

The meeting was also an excellent chance to network with other big names in the GAIA project, which really is going to be the biggest thing in European astronomy for the next few years. I also had plenty of opportunity to bond with Stu (my co-supervisor), and very much enjoyed his recounted tales of when he was a PhD student under Vik (my primary supervisor). I’m now quite looking forward to spending 5 nights at the William Herschel Telescope, being trained by Stu on how to use ULTRACAM.

Notre Dame Catheral

Notre Dame Catheral

Most importantly though, there was free juice and croissants. Brilliant!

Coding is fun

It’s been almost three weeks since my last post, so I’ve got some catching up to do. The key aspects will follow in the next few posts, but first here is a quick self-promoting “yay!” for myself and my improving Python scripting abilities. In my last week in the office before heading on an assortment of adventures (see following posts), I managed to code up some useful Python modules for use on the pt5m. Hurray! Now I actually deserve at least a tiny bit of credit for being part of the team. Anyway, here is some code to automatically create bias and flat field frames (with assistance from Stu Littlefair). Enjoy:

#!/usr/bin/env python
from pyraf import iraf
import sys
import os, glob
from optparse import OptionParser
import datetime

def getOktal():
    # import current conditions into dictionary 
    # (function parseConditions from home/slodar/scripts/qsi_daemon.py)   
    f = open('/home/slodar/config/conditions_monitor')
    line = f.read().strip()
    condDict = {}
    columns = line.split()
    condDict['cond-date'] = columns[1]+"T"+columns[2]
    dt = datetime.datetime.strptime(condDict['cond-date'],'%Y-%m-%dT%H:%M:%S')
    age = datetime.datetime.utcnow()-dt
    age_seconds = 86400*age.days + age.seconds
    if (age_seconds > 900):
        raise Exception('Conditions log out of date')
    condDict.update( dict([columns[i+3].split('=') for i in range(len(columns)-3)]) )
    # read new paramter skyT as float
    skyT = float(condDict['sky_temp'])
    # convert to oktal 
    # (function temp2oktal from home/slodar/scripts/qsi_daemon.py)   
    p0 = -16.749332
    p1 = 2.88788
    oktal = (skyT-p0)/p1
    return oktal

def cleanupFiles(data_dir):
    cals_dir = data_dir + 'calibs/'
    files=glob.glob(data_dir+'db*')
    files.extend( glob.glob('*.lis') )
    files.extend( glob.glob(cals_dir + '*flat.fits') )
    for filename in files:
        os.remove(filename)
    os.remove('allFits')
    return

def parseCmdLineArgs():
    usage = "usage: %prog [--live] dir_name"
    parser = OptionParser(usage=usage)
    parser.add_option("-l", "--live",action="store_true", 
        dest="live_flag",default=False,help="script being run live on ron?")

    (options, args) = parser.parse_args()  

    live_flag = options.live_flag

    if(len(args) == 1):
        data_dir = args[0]
        # check if data_dir ends in '/', if not, add it
        if not data_dir.endswith('/'): 
            data_dir=data_dir+'/'       
    else:
        # if data directory left blank, use this directory
        data_dir = './'
    return (data_dir,live_flag)

def makeMasterFlatFrames(cals_dir,filt):

    #assume flats are 1x1 (they should be), check for suitable bias
    if not os.path.exists(cals_dir+'bias1x1.fits'):
        print 'no 1x1 bias available this night, aborting'
        return
    else:
        biasFrame = cals_dir+'bias1x1.fits'
    
    matchExpr = "TYPE='SKY' && FILTER='%s'" % filt
    flatlis = iraf.hsel(images='@allFits',fields='$I',expr=matchExpr,Stdout=1)

    #write list files for each filter
    listFile = filt+'flat.lis'
    f = open(listFile, 'w')
    for flat in flatlis:
        f.write(flat + '\n')
    f.close()

    #check if >2 flats exist, if not, continue with next filter    
    if len(flatlis) >2:

        #write de-biassed list filenames for each filter
        dbListFile = filt+'flatdb.lis'
        f = open(dbListFile, 'w')
        for flat in flatlis:    
            head,tail=os.path.split(flat)
            f.write(head+'/db'+tail+'\n')
        f.close()

        #subtract 1x1 bias frame from flats
        iraf.imarith(operand1='@'+listFile,op='-',operand2=biasFrame,result='@'+dbListFile)
        print filt+'-band flats de-biassed'

        # combine de-biassed flat fields, with scaling
        outIm = cals_dir+filt+'flat.fits'
        iraf.imcombine(input='@'+dbListFile,output=outIm,combine='median',reject='avsigclip',scale='mode',statsec='[900:1000,650:750]',Stdout=1)
        print 'Master '+filt+'-band flat created'

        #calculate normalisation constant
        norm_const=iraf.imstat(image=outIm,fields='mean',format=0,Stdout=1)
        norm_const=float(norm_const[0])

        #normalise!        
        iraf.imarith(operand1=outIm,op='/',operand2=norm_const,result=cals_dir+filt+'flatnorm1x1.fits')        
        print 'Master '+filt+'-band flat normalised'

        #create binned flats for each filter     ***using 'average' rather than sum***
        iraf.blkavg(input=cals_dir+filt+'flatnorm1x1.fits',output=cals_dir+filt+'flatnorm2x2.fits',b1=2,b2=2,option='average')
        print 'Master '+filt+'-band 2x2 flat created'

        iraf.blkavg(input=cals_dir+filt+'flatnorm1x1.fits',output=cals_dir+filt+'flatnorm3x3.fits',b1=3,b2=3,option='average')
        print 'Master '+filt+'-band 3x3 flat created'

    # if no flats of this filter exist, move to next filter
    else:
        print 'Less than 3 '+filt+'-band flats available. Filter skipped'
        return


def makeMasterBiasFrames(cals_dir,bin):
    bin = str(bin)
    
    matchExpr = "TYPE='BIAS' && XBINNING=%s" % bin
    
    # find matching biasses
    biaslis = iraf.hsel(images='@allFits',fields='$I',expr=matchExpr,Stdout=1)

    #write list files for each 
    listFile = 'bias'+bin+'.lis'
    f = open(listFile, 'w')
    for bias in biaslis:
        f.write(bias + '\n')
    f.close()
    
    #combine to create master biases
    if len(biaslis) > 2:
        imOut = cals_dir + 'bias'+bin+'x'+bin+'.fits'
        iraf.imcombine(input='@'+listFile,output=imOut,combine='median',Stdout=1)
        print 'Binning '+bin+'x'+bin+' bias created'
    else:
        print 'Too few '+bin+'x'+bin+' biases to combine'


if __name__ == "__main__":
    data_dir, live_flag = parseCmdLineArgs()

    # allow iraf to overwrite existing files
    iraf.reset(clobber='yes')

    # always put calibrations in calibs, for consistency
    cals_dir=data_dir+'calibs/'
    if not os.path.exists(cals_dir):
        os.mkdir(cals_dir)

    # 'hsel' is not always available by default, load images package
    iraf.images(_doprint=0)

    # select all frames
    # filename template must ignore any _cat.fits files...
    iraf.files(data_dir+'r*[0-9].fits',Stdout='allFits')


    ###############################
    ## Biasses ##
    for bin in ['1','2','3']:
        try:
            makeMasterBiasFrames(cals_dir,bin)
        except Exception as e:
            print 'Encountered error making bias'
            print e
            print 'Continuing'
            

    # when running live, check for cloud levels
    # abort script at this point if cloud present
    if live_flag:
        try:
            oktal = getOktal()
        except Exception as e:
            print 'could not get cloud conditions, aborting'
            print e
            cleanupFiles(data_dir)
            sys.exit()

        # if oktal above zero, abort script here
        if oktal > 0.0:
            print 'Suspect cloudy conditions. Aborting script here. No master flats created.'
            ## delete used files ##
            cleanupFiles(data_dir)
            sys.exit()


    ################################
    ## Flats ##
    filters = ['H','B','V','R','I']
    for filt in filters:
        try:
            makeMasterFlatFrames(cals_dir,filt)
        except Exception as e:
            print 'Encountered error making flat'
            print e
            print 'Continuing'
        
    cleanupFiles(data_dir)