def atc_station_tracer_query(station_code, samp_height, tracer, level=2):

    """
        Return SPARQL query to get a data object for 
        a specific ICOS Atmospheric station, sampling height and tracer
         CO2, CO or MTO, level 2 or level 1 (=NRT)
       :input: ATC station code, sampling height, tracer, ICOS data level (default=2)
       :return: SPARQL query to get all ATC Level <level> products for tracer <tracer>
       :rtype: string 
    """
    
    station_label = 'AS_' + station_code
    tracer = tracer.lower().title()
    dataobject = ['NrtGrowingDataObject','L2DataObject']    
  
    #Define URL:
    url = 'https://meta.icos-cp.eu/sparql'
    
    query = """
        prefix cpmeta: <http://meta.icos-cp.eu/ontologies/cpmeta/>
        prefix prov: <http://www.w3.org/ns/prov#>
        select ?dobj ?spec ?fileName ?size ?submTime ?timeStart ?timeEnd ?samplingHeight
        where {
            VALUES ?spec {<http://meta.icos-cp.eu/resources/cpmeta/atc"""+tracer+dataobject[level-1]+""">}
            ?dobj cpmeta:hasObjectSpec ?spec .
            VALUES ?station {<http://meta.icos-cp.eu/resources/stations/"""+station_label+""">}
            ?dobj cpmeta:wasAcquiredBy/prov:wasAssociatedWith ?station .
            ?dobj cpmeta:hasSizeInBytes ?size .
            ?dobj cpmeta:hasName ?fileName .
            ?dobj cpmeta:wasSubmittedBy/prov:endedAtTime ?submTime .
            ?dobj cpmeta:hasStartTime | (cpmeta:wasAcquiredBy / prov:startedAtTime) ?timeStart .
            ?dobj cpmeta:hasEndTime | (cpmeta:wasAcquiredBy / prov:endedAtTime) ?timeEnd .
            FILTER NOT EXISTS {[] cpmeta:isNextVersionOf ?dobj}
            ?dobj cpmeta:wasAcquiredBy / cpmeta:hasSamplingHeight ?samplingHeight .
            FILTER( ?samplingHeight = '"""+str(samp_height)+"""'^^xsd:float )
        }
        order by desc(?submTime)
    """
    return query