def generate_sta_locations(db, mtype, deploytype, year, month, verbose=False, debug=False):
    """Generate station locations for specific
    periods in time and write out to xy files 
    suitable for GMT
    """
    start_time, end_time = generate_times(year, month)

    # Get the networks
    snetptr = antdb.dbopen(db, 'r')
    snetptr = antdb.dbprocess(snetptr,
                            ['dbopen site',
                             'dbjoin snetsta',
                             'dbjoin deployment'])
    snetptr = antdb.dbsort(snetptr,'snet', unique=True)
    usnets = []
    try:
        for i in range(antdb.dbquery(snetptr, antdb.dbRECORD_COUNT )):
            snetptr['record'] = i
            mysnet = antdb.dbgetv(snetptr,'snet')[0]
            usnets.append(mysnet)
        antdb.dbclose(snetptr)
    except Exception, e:
        print "generate_sta_locations(): Exception occurred: %s" % e
            infra_tmp_decom = tempfile.mkstemp(
              suffix='.xy',
              prefix='deployment_list_inframet_DECOM_'
            )
            # Add the DECOM by hand as it is a manufactured
            # file, not a snet per se. Call it _DECOM to force
            # it to plot first
            file_list['1_DECOM'] = infra_tmp_decom[1]
            counter['decom'] = 0
        try:
            infraptr_grp = antdb.dbgroup(infraptr, 'sta')
        except Exception,e:
            print "  - generate_inframet_locations(): Dbgroup failed with exception: %s" % e
        else:
            # Get values into a easily digestible dict
            for i in range(antdb.dbquery(infraptr_grp, antdb.dbRECORD_COUNT)):
                infraptr_grp[3] = i
                sta, [db, view, end_rec, start_rec] = \
                    antdb.dbgetv(infraptr_grp, 'sta', 'bundle')
                all_stations[sta] = {'sensors': {'MEMS':False, 'NCPA':False,
                                                 'SETRA':False},
                                     'location': {'lat':0, 'lon':0}}
                for j in range(start_rec, end_rec):
                    infraptr[3] = j
                    # Cannot use time or endtime as that applies to the station, not to the inframet sensor
                    ondate, offdate, chan, lat, lon = \
                        antdb.dbgetv(infraptr, 'ondate', 'offdate', 'chan', 'lat', 'lon')
                    all_stations[sta]['location']['lat'] = lat
                    all_stations[sta]['location']['lon'] = lon

                    ondate = epoch(ondate)