Пример #1
0
def listADDEImages(localEntry=None,
    server=None, dataset=None, descriptor=None,
    accounting=DEFAULT_ACCOUNTING,
    location=None,
    coordinateSystem=CoordinateSystems.LATLON,
    place=None,
    mag=None,
    position=None,
    unit=None,
    day=None,
    time=None,
    debug=False,
    band=None,
    size=None,
    showUrls=True):
    """Creates a list of ADDE images.
    
    Args:
        localEntry: Local ADDE dataset.
        server: ADDE server.
        dataset: ADDE dataset group name.
        descriptor: ADDE dataset descriptor.
        day: Day range. ('begin date', 'end date')
        time: ('begin time', 'end time')
        position: Position number. Values may be integers or the string "ALL". (default=0)
        band: McIDAS band number; only images that have matching band number will be returned.
        accounting: ('user', 'project number') User and project number required by servers using McIDAS accounting. default = ('idv','0')
        
    Returns:
        ADDE image matching the given criteria, if any.
    """
    if localEntry:
        server = localEntry.getAddress()
        dataset = localEntry.getGroup()
        descriptor = localEntry.getDescriptor().upper()
    elif (server is None) or (dataset is None) or (descriptor is None):
        raise TypeError("must provide localEntry or server, dataset, and descriptor values.")
        
    if server == "localhost" or server == "127.0.0.1":
        port = EntryStore.getLocalPort()
    else:
        port = "112"
        
    # server = '%s:%s' % (server, port)
    
    user = accounting[0]
    proj = accounting[1]
    debug = str(debug).lower()
    
    if mag:
        mag = '&MAG=%s %s' % (mag[0], mag[1])
    else:
        mag = ''
        
    if unit:
        origUnit = unit
        unit = '&UNIT=%s' % (unit)
    else:
        # origUnit = None
        unit = ''
        
    if place is Places.CENTER:
        place = '&PLACE=CENTER'
    elif place is Places.ULEFT:
        place = '&PLACE=ULEFT'
    else:
        # raise ValueError()
        place = ''
        
    if coordinateSystem is CoordinateSystems.LATLON:
        coordSys = 'LATLON'
    elif coordinateSystem is CoordinateSystems.AREA or coordinateSystem is CoordinateSystems.IMAGE:
        coordSys = 'LINELE'
    else:
        raise ValueError()
        
    if location:
        location = '&%s=%s %s' % (coordSys, location[0], location[1])
    else:
        location = ''
        
    if size:
        if size == 'ALL':
            size = '&SIZE=99999 99999'
        else:
            size = '&SIZE=%s %s' % (size[0], size[1])
    else:
        size = ''
        
    if time:
        time = '&TIME=%s %s I' % (time[0], time[1])
    else:
        time = ''
        
    if band:
        band = '&BAND=%s' % (str(band))
    else:
        band = '&BAND=ALL'
        
    if position is not None:
        if isinstance(position, int):
            position = '&POS=%s' % (position)
        elif isinstance(position, tuple):
            if len(position) != 2:
                raise ValueError('position range may only contain values for the beginning and end of a range.')
            position = '&POS=%s %s' % (str(position[0]), str(position[1]))
        else:
            position = '&POS=%s' % (str(position).upper())
    else:
        position = '&POS=0'
        
    tz = TimeZone.getTimeZone('Z')
    
    dateFormat = SimpleDateFormat()
    dateFormat.setTimeZone(tz)
    dateFormat.applyPattern('yyyyDDD')
    
    timeFormat = SimpleDateFormat();
    timeFormat.setTimeZone(tz)
    timeFormat.applyPattern('HH:mm:ss')
    
    addeUrlFormat = "adde://%(server)s/imagedirectory?&PORT=%(port)s&COMPRESS=gzip&USER=%(user)s&PROJ=%(proj)s&VERSION=1&DEBUG=%(debug)s&TRACE=0&GROUP=%(dataset)s&DESCRIPTOR=%(descriptor)s%(band)s%(location)s%(place)s%(size)s%(unit)s%(mag)s%(day)s%(time)s%(position)s"
    
    urls = []
    areaDirectories = []
    
    dates = _normalizeDates(day)
    for date in dates:
        formatValues = {
            'server': server,
            'port': port,
            'user': user,
            'proj': proj,
            'debug': debug,
            'dataset': dataset,
            'descriptor': descriptor,
            'band': band,
            'location': location,
            'place': place,
            'size': size,
            'unit': unit,
            'mag': mag,
            'day': date,
            'time': time,
            'position': position,
        }
        url = addeUrlFormat % formatValues
        if showUrls:
            print url
        adl = AreaDirectoryList(url)
        results = adl.getSortedDirs()
        for imageTimes in results:
            for areaDirectory in imageTimes:
                urls.append(url)
                areaDirectories.append(areaDirectory)
                
    temp = _AreaDirectoryList()
    for i, d in enumerate(areaDirectories):
        nominalTime = d.getNominalTime()
        tempDay = str(dateFormat.format(nominalTime, StringBuffer(), FieldPosition(0)))
        tempTime = str(timeFormat.format(nominalTime, StringBuffer(), FieldPosition(0)))
        
        bandList = list(d.getBands())
        # tempUnitList = list(d.getCalInfo()[0])
        # unitList = tempUnitList[::2]
        # unitDescList = tempUnitList[1::2]
        # calInfo = dict(zip(unitList, unitDescList))
        if unit:
            unitList = [origUnit]
        else:
            unitList = map(str, list(d.getCalInfo()[0])[::2])
            
        for band in bandList:
            for calUnit in unitList:
                dt = {
                    'server': server,
                    'dataset': dataset,
                    'descriptor': descriptor,
                    'bandNumber': band,
                    'bandList': bandList,
                    'debug': debug,
                    'accounting': accounting,
                    'day': tempDay,
                    'time': tempTime,
                    'imageSize': (d.getLines(), d.getElements()),
                    'centerLocation': (d.getCenterLatitude(), d.getCenterLongitude()),
                    'resolution': (d.getCenterLatitudeResolution(), d.getCenterLongitudeResolution()),
                    'unitList': unitList,
                    'unitType': calUnit,
                    'bands': bandList,
                    'band-count': d.getNumberOfBands(),
                    'calinfo': map(str, list(d.getCalInfo()[0])),
                    'calibration-scale-factor': d.getCalibrationScaleFactor(),
                    'calibration-type': str(d.getCalibrationType()),
                    'calibration-unit-name': d.getCalibrationUnitName(),
                    'center-latitude': d.getCenterLatitude(),
                    'center-latitude-resolution': d.getCenterLatitudeResolution(),
                    'center-longitude': d.getCenterLongitude(),
                    'center-longitude-resolution': d.getCenterLongitudeResolution(),
                    'directory-block': list(d.getDirectoryBlock()),
                    'elements': d.getElements(),
                    'lines': d.getLines(),
                    'memo-field': str(d.getMemoField()),
                    'nominal-time': DateTime(d.getNominalTime()),
                    'sensor-id': d.getSensorID(),
                    'sensor-type': str(d.getSensorType()),
                    'source-type': str(d.getSourceType()),
                    'start-time': DateTime(d.getStartTime()),
                    'url': urls[i],
                }
            temp.append(dt)
    return temp
Пример #2
0
def listADDEImageTimes(localEntry=None,
    server=None, dataset=None, descriptor=None,
    accounting=DEFAULT_ACCOUNTING,
    location=None,
    coordinateSystem=CoordinateSystems.LATLON,
    place=None,
    mag=None,
    position=None,
    unit=None,
    day=None,
    time=None,
    debug=False,
    band=None,
    size=None,
    showUrls=True):
    
    if localEntry:
        server = localEntry.getAddress()
        dataset = localEntry.getGroup()
        descriptor = localEntry.getDescriptor().upper()
    elif (server is None) or (dataset is None) or (descriptor is None):
        raise TypeError("must provide localEntry or server, dataset, and descriptor values.")
        
    if server == "localhost" or server == "127.0.0.1":
        port = EntryStore.getLocalPort()
    else:
        port = "112"
        
    # server = '%s:%s' % (server, port)
    
    user = accounting[0]
    proj = accounting[1]
    debug = str(debug).lower()
    
    if mag:
        mag = '&MAG=%s %s' % (mag[0], mag[1])
    else:
        mag = ''
        
    if unit:
        origUnit = unit
        unit = '&UNIT=%s' % (unit)
    else:
        # origUnit = None
        unit = ''
        
    if place is Places.CENTER:
        place = '&PLACE=CENTER'
    elif place is Places.ULEFT:
        place = '&PLACE=ULEFT'
    else:
        # raise ValueError()
        place = ''
        
    if coordinateSystem is CoordinateSystems.LATLON:
        coordSys = 'LATLON'
    elif coordinateSystem is CoordinateSystems.AREA or coordinateSystem is CoordinateSystems.IMAGE:
        coordSys = 'LINELE'
    else:
        raise ValueError()
        
    if location:
        location = '&%s=%s %s' % (coordSys, location[0], location[1])
    else:
        location = ''
        
    if size:
        if size == 'ALL':
            size = '&SIZE=99999 99999'
        else:
            size = '&SIZE=%s %s' % (size[0], size[1])
    else:
        size = ''
        
    if time:
        time = '&TIME=%s %s I' % (time[0], time[1])
    else:
        time = ''
        
    if band:
        band = '&BAND=%s' % (str(band))
    else:
        band = '&BAND=ALL'
        
    if position is not None:
        if isinstance(position, int):
            position = '&POS=%s' % (position)
        elif isinstance(position, tuple):
            if len(position) != 2:
                raise ValueError('position range may only contain values for the beginning and end of a range.')
            position = '&POS=%s %s' % (str(position[0]), str(position[1]))
        else:
            position = '&POS=%s' % (str(position).upper())
    else:
        position = '&POS=0'
        
    tz = TimeZone.getTimeZone('Z')
    
    dateFormat = SimpleDateFormat()
    dateFormat.setTimeZone(tz)
    dateFormat.applyPattern('yyyyDDD')
    
    timeFormat = SimpleDateFormat();
    timeFormat.setTimeZone(tz)
    timeFormat.applyPattern('HH:mm:ss')
    
    addeUrlFormat = "adde://%(server)s/imagedirectory?&PORT=%(port)s&COMPRESS=gzip&USER=%(user)s&PROJ=%(proj)s&VERSION=1&DEBUG=%(debug)s&TRACE=0&GROUP=%(dataset)s&DESCRIPTOR=%(descriptor)s%(band)s%(location)s%(place)s%(size)s%(unit)s%(mag)s%(day)s%(time)s%(position)s"
    
    urls = []
    areaDirectories = []
    
    dates = _normalizeDates(day)
    for date in dates:
        formatValues = {
            'server': server,
            'port': port,
            'user': user,
            'proj': proj,
            'debug': debug,
            'dataset': dataset,
            'descriptor': descriptor,
            'band': band,
            'location': location,
            'place': place,
            'size': size,
            'unit': unit,
            'mag': mag,
            'day': date,
            'time': time,
            'position': position,
        }
        url = addeUrlFormat % formatValues
        if showUrls:
            print url
        adl = AreaDirectoryList(url)
        results = adl.getSortedDirs()
        for imageTimes in results:
            for areaDirectory in imageTimes:
                urls.append(url)
                areaDirectories.append(areaDirectory)
                
    uniques = set()
    times = []
    for d in areaDirectories:
        dt = DateTime(d.getNominalTime())
        if dt not in uniques:
            d = { 
                'day': str(dt.formattedString('yyyyDDD', tz)), 
                'time': str(dt.formattedString('HH:mm:ss', tz)),
            }
            times.append(d)
            uniques.add(dt)
    uniques = None
    return sorted(times)
Пример #3
0
def listADDEImageTimes(localEntry=None,
                       server=None,
                       dataset=None,
                       descriptor=None,
                       accounting=DEFAULT_ACCOUNTING,
                       location=None,
                       coordinateSystem=CoordinateSystems.LATLON,
                       place=None,
                       mag=None,
                       position=None,
                       unit=None,
                       day=None,
                       time=None,
                       debug=False,
                       band=None,
                       size=None,
                       showUrls=True):

    if localEntry:
        server = localEntry.getAddress()
        dataset = localEntry.getGroup()
        descriptor = localEntry.getDescriptor().upper()
    elif (server is None) or (dataset is None) or (descriptor is None):
        raise TypeError(
            "must provide localEntry or server, dataset, and descriptor values."
        )

    if server == "localhost" or server == "127.0.0.1":
        port = EntryStore.getLocalPort()
    else:
        port = "112"

    # server = '%s:%s' % (server, port)

    user = accounting[0]
    proj = accounting[1]
    debug = str(debug).lower()

    if mag:
        mag = '&MAG=%s %s' % (mag[0], mag[1])
    else:
        mag = ''

    if unit:
        origUnit = unit
        unit = '&UNIT=%s' % (unit)
    else:
        # origUnit = None
        unit = ''

    if place is Places.CENTER:
        place = '&PLACE=CENTER'
    elif place is Places.ULEFT:
        place = '&PLACE=ULEFT'
    else:
        # raise ValueError()
        place = ''

    if coordinateSystem is CoordinateSystems.LATLON:
        coordSys = 'LATLON'
    elif coordinateSystem is CoordinateSystems.AREA or coordinateSystem is CoordinateSystems.IMAGE:
        coordSys = 'LINELE'
    else:
        raise ValueError()

    if location:
        location = '&%s=%s %s' % (coordSys, location[0], location[1])
    else:
        location = ''

    if size:
        if size == 'ALL':
            size = '&SIZE=99999 99999'
        else:
            size = '&SIZE=%s %s' % (size[0], size[1])
    else:
        size = ''

    if time:
        time = '&TIME=%s %s I' % (time[0], time[1])
    else:
        time = ''

    if band:
        band = '&BAND=%s' % (str(band))
    else:
        band = '&BAND=ALL'

    if position is not None:
        if isinstance(position, int):
            position = '&POS=%s' % (position)
        elif isinstance(position, tuple):
            if len(position) != 2:
                raise ValueError(
                    'position range may only contain values for the beginning and end of a range.'
                )
            position = '&POS=%s %s' % (str(position[0]), str(position[1]))
        else:
            position = '&POS=%s' % (str(position).upper())
    else:
        position = '&POS=0'

    tz = TimeZone.getTimeZone('Z')

    dateFormat = SimpleDateFormat()
    dateFormat.setTimeZone(tz)
    dateFormat.applyPattern('yyyyDDD')

    timeFormat = SimpleDateFormat()
    timeFormat.setTimeZone(tz)
    timeFormat.applyPattern('HH:mm:ss')

    addeUrlFormat = "adde://%(server)s/imagedirectory?&PORT=%(port)s&COMPRESS=gzip&USER=%(user)s&PROJ=%(proj)s&VERSION=1&DEBUG=%(debug)s&TRACE=0&GROUP=%(dataset)s&DESCRIPTOR=%(descriptor)s%(band)s%(location)s%(place)s%(size)s%(unit)s%(mag)s%(day)s%(time)s%(position)s"

    urls = []
    areaDirectories = []

    dates = _normalizeDates(day)
    for date in dates:
        formatValues = {
            'server': server,
            'port': port,
            'user': user,
            'proj': proj,
            'debug': debug,
            'dataset': dataset,
            'descriptor': descriptor,
            'band': band,
            'location': location,
            'place': place,
            'size': size,
            'unit': unit,
            'mag': mag,
            'day': date,
            'time': time,
            'position': position,
        }
        url = addeUrlFormat % formatValues
        if showUrls:
            print url
        adl = AreaDirectoryList(url)
        results = adl.getSortedDirs()
        for imageTimes in results:
            for areaDirectory in imageTimes:
                urls.append(url)
                areaDirectories.append(areaDirectory)

    uniques = set()
    times = []
    for d in areaDirectories:
        dt = DateTime(d.getNominalTime())
        if dt not in uniques:
            d = {
                'day': str(dt.formattedString('yyyyDDD', tz)),
                'time': str(dt.formattedString('HH:mm:ss', tz)),
            }
            times.append(d)
            uniques.add(dt)
    uniques = None
    return sorted(times)
Пример #4
0
def listADDEImages(localEntry=None,
                   server=None,
                   dataset=None,
                   descriptor=None,
                   accounting=DEFAULT_ACCOUNTING,
                   location=None,
                   coordinateSystem=CoordinateSystems.LATLON,
                   place=None,
                   mag=None,
                   position=None,
                   unit=None,
                   day=None,
                   time=None,
                   debug=False,
                   band=None,
                   size=None,
                   showUrls=True):
    """Creates a list of ADDE images.
    
    Args:
        localEntry: Local ADDE dataset.
        server: ADDE server.
        dataset: ADDE dataset group name.
        descriptor: ADDE dataset descriptor.
        day: Day range. ('begin date', 'end date')
        time: ('begin time', 'end time')
        position: Position number. Values may be integers or the string "ALL". (default=0)
        band: McIDAS band number; only images that have matching band number will be returned.
        accounting: ('user', 'project number') User and project number required by servers using McIDAS accounting. default = ('idv','0')
        
    Returns:
        ADDE image matching the given criteria, if any.
    """
    if localEntry:
        server = localEntry.getAddress()
        dataset = localEntry.getGroup()
        descriptor = localEntry.getDescriptor().upper()
    elif (server is None) or (dataset is None) or (descriptor is None):
        raise TypeError(
            "must provide localEntry or server, dataset, and descriptor values."
        )

    if server == "localhost" or server == "127.0.0.1":
        port = EntryStore.getLocalPort()
    else:
        port = "112"

    # server = '%s:%s' % (server, port)

    user = accounting[0]
    proj = accounting[1]
    debug = str(debug).lower()

    if mag:
        mag = '&MAG=%s %s' % (mag[0], mag[1])
    else:
        mag = ''

    if unit:
        origUnit = unit
        unit = '&UNIT=%s' % (unit)
    else:
        # origUnit = None
        unit = ''

    if place is Places.CENTER:
        place = '&PLACE=CENTER'
    elif place is Places.ULEFT:
        place = '&PLACE=ULEFT'
    else:
        # raise ValueError()
        place = ''

    if coordinateSystem is CoordinateSystems.LATLON:
        coordSys = 'LATLON'
    elif coordinateSystem is CoordinateSystems.AREA or coordinateSystem is CoordinateSystems.IMAGE:
        coordSys = 'LINELE'
    else:
        raise ValueError()

    if location:
        location = '&%s=%s %s' % (coordSys, location[0], location[1])
    else:
        location = ''

    if size:
        if size == 'ALL':
            size = '&SIZE=99999 99999'
        else:
            size = '&SIZE=%s %s' % (size[0], size[1])
    else:
        size = ''

    if time:
        time = '&TIME=%s %s I' % (time[0], time[1])
    else:
        time = ''

    if band:
        band = '&BAND=%s' % (str(band))
    else:
        band = '&BAND=ALL'

    if position is not None:
        if isinstance(position, int):
            position = '&POS=%s' % (position)
        elif isinstance(position, tuple):
            if len(position) != 2:
                raise ValueError(
                    'position range may only contain values for the beginning and end of a range.'
                )
            position = '&POS=%s %s' % (str(position[0]), str(position[1]))
        else:
            position = '&POS=%s' % (str(position).upper())
    else:
        position = '&POS=0'

    tz = TimeZone.getTimeZone('Z')

    dateFormat = SimpleDateFormat()
    dateFormat.setTimeZone(tz)
    dateFormat.applyPattern('yyyyDDD')

    timeFormat = SimpleDateFormat()
    timeFormat.setTimeZone(tz)
    timeFormat.applyPattern('HH:mm:ss')

    addeUrlFormat = "adde://%(server)s/imagedirectory?&PORT=%(port)s&COMPRESS=gzip&USER=%(user)s&PROJ=%(proj)s&VERSION=1&DEBUG=%(debug)s&TRACE=0&GROUP=%(dataset)s&DESCRIPTOR=%(descriptor)s%(band)s%(location)s%(place)s%(size)s%(unit)s%(mag)s%(day)s%(time)s%(position)s"

    urls = []
    areaDirectories = []

    dates = _normalizeDates(day)
    for date in dates:
        formatValues = {
            'server': server,
            'port': port,
            'user': user,
            'proj': proj,
            'debug': debug,
            'dataset': dataset,
            'descriptor': descriptor,
            'band': band,
            'location': location,
            'place': place,
            'size': size,
            'unit': unit,
            'mag': mag,
            'day': date,
            'time': time,
            'position': position,
        }
        url = addeUrlFormat % formatValues
        if showUrls:
            print url
        adl = AreaDirectoryList(url)
        results = adl.getSortedDirs()
        for imageTimes in results:
            for areaDirectory in imageTimes:
                urls.append(url)
                areaDirectories.append(areaDirectory)

    temp = _AreaDirectoryList()
    for i, d in enumerate(areaDirectories):
        nominalTime = d.getNominalTime()
        tempDay = str(
            dateFormat.format(nominalTime, StringBuffer(), FieldPosition(0)))
        tempTime = str(
            timeFormat.format(nominalTime, StringBuffer(), FieldPosition(0)))

        bandList = list(d.getBands())
        # tempUnitList = list(d.getCalInfo()[0])
        # unitList = tempUnitList[::2]
        # unitDescList = tempUnitList[1::2]
        # calInfo = dict(zip(unitList, unitDescList))
        if unit:
            unitList = [origUnit]
        else:
            unitList = map(str, list(d.getCalInfo()[0])[::2])

        for band in bandList:
            for calUnit in unitList:
                dt = {
                    'server':
                    server,
                    'dataset':
                    dataset,
                    'descriptor':
                    descriptor,
                    'bandNumber':
                    band,
                    'bandList':
                    bandList,
                    'debug':
                    debug,
                    'accounting':
                    accounting,
                    'day':
                    tempDay,
                    'time':
                    tempTime,
                    'imageSize': (d.getLines(), d.getElements()),
                    'centerLocation':
                    (d.getCenterLatitude(), d.getCenterLongitude()),
                    'resolution': (d.getCenterLatitudeResolution(),
                                   d.getCenterLongitudeResolution()),
                    'unitList':
                    unitList,
                    'unitType':
                    calUnit,
                    'bands':
                    bandList,
                    'band-count':
                    d.getNumberOfBands(),
                    'calinfo':
                    map(str, list(d.getCalInfo()[0])),
                    'calibration-scale-factor':
                    d.getCalibrationScaleFactor(),
                    'calibration-type':
                    str(d.getCalibrationType()),
                    'calibration-unit-name':
                    d.getCalibrationUnitName(),
                    'center-latitude':
                    d.getCenterLatitude(),
                    'center-latitude-resolution':
                    d.getCenterLatitudeResolution(),
                    'center-longitude':
                    d.getCenterLongitude(),
                    'center-longitude-resolution':
                    d.getCenterLongitudeResolution(),
                    'directory-block':
                    list(d.getDirectoryBlock()),
                    'elements':
                    d.getElements(),
                    'lines':
                    d.getLines(),
                    'memo-field':
                    str(d.getMemoField()),
                    'nominal-time':
                    DateTime(d.getNominalTime()),
                    'sensor-id':
                    d.getSensorID(),
                    'sensor-type':
                    str(d.getSensorType()),
                    'source-type':
                    str(d.getSourceType()),
                    'start-time':
                    DateTime(d.getStartTime()),
                    'url':
                    urls[i],
                }
            temp.append(dt)
    return temp
Пример #5
0
def listADDEImages(server, dataset, descriptor,
    accounting=DEFAULT_ACCOUNTING,
    location=None,
    coordinateSystem=CoordinateSystems.LATLON,
    place=None,
    mag=None,
    position=0,
    unit=None,
    day=None,
    time=None,
    debug=False,
    band=None,
    size=None):
    """Creates a list of ADDE images.
    
    Args:
        localEntry: Local ADDE dataset.
        server: ADDE server.
        dataset: ADDE dataset group name.
        descriptor: ADDE dataset descriptor.
        day: Day range. ('begin date', 'end date')
        time: ('begin time', 'end time')
        position: Position number. Values may be integers or the string "ALL". (default=0)
        band: McIDAS band number; only images that have matching band number will be returned.
        accounting: ('user', 'project number') User and project number required by servers using McIDAS accounting. default = ('idv','0')
        
    Returns:
        ADDE image matching the given criteria, if any.
    """
    
    user = accounting[0]
    proj = accounting[1]
    debug = str(debug).lower()
    
    if mag:
        mag = '&MAG=%s %s' % (mag[0], mag[1])
    else:
        mag = ''
        
    if unit:
        unit = '&UNIT=%s' % (unit)
    else:
        unit = ''
        
    if place is Places.CENTER:
        place = '&PLACE=CENTER'
    elif place is Places.ULEFT:
        place = '&PLACE=ULEFT'
    else:
        # raise ValueError()
        place = ''
        
    if coordinateSystem is CoordinateSystems.LATLON:
        coordSys = 'LATLON'
    elif coordinateSystem is CoordinateSystems.AREA or coordinateSystem is CoordinateSystems.IMAGE:
        coordSys = 'LINELE'
    else:
        raise ValueError()
        
    if location:
        location = '%s=%s %s' % (coordSys, location[0], location[1])
    else:
        location = ''
        
    if size:
        if size == 'ALL':
            size = '&SIZE=99999 99999'
        else:
            size = '&SIZE=%s %s' % (size[0], size[1])
    else:
        size = ''
        
    if time:
        time = '&TIME=%s %s I' % (time[0], time[1])
    else:
        time = ''
        
    if band:
        band = '&BAND=%s' % (str(band))
    else:
        band = '&BAND=ALL'
        
    tz = TimeZone.getTimeZone("Z")
    
    dateFormat = SimpleDateFormat()
    dateFormat.setTimeZone(tz)
    dateFormat.applyPattern('yyyyDDD')
    
    timeFormat = SimpleDateFormat();
    timeFormat.setTimeZone(tz)
    timeFormat.applyPattern('HH:mm:ss')
    
    addeUrlFormat = "adde://%(server)s/imagedirectory?&PORT=112&COMPRESS=gzip&USER=%(user)s&PROJ=%(proj)s&VERSION=1&DEBUG=%(debug)s&TRACE=0&GROUP=%(dataset)s&DESCRIPTOR=%(descriptor)s%(band)s%(location)s%(place)s%(size)s%(unit)s%(mag)s%(day)s%(time)s&POS=%(position)s"
    
    areaDirectories = []
    
    dates = _normalizeDates(day)
    if not dates:
        formatValues = {
            'server': server,
            'user': user,
            'proj': proj,
            'debug': debug,
            'dataset': dataset,
            'descriptor': descriptor,
            'band': band,
            'location': location,
            'place': place,
            'size': size,
            'unit': unit,
            'mag': mag,
            'day': '',
            'time': time,
            'position': position,
        }
        url = addeUrlFormat % formatValues
        print url
        adl = AreaDirectoryList(url)
        dirs = adl.getSortedDirs()
        for areaDirectory in dirs[0]:
            areaDirectories.append(areaDirectory)
    else:
        for date in dates:
            urlDate = '&DAY=%s' % (date)
            formatValues = {
                'server': server,
                'user': user,
                'proj': proj,
                'debug': debug,
                'dataset': dataset,
                'descriptor': descriptor,
                'band': band,
                'location': location,
                'place': place,
                'size': size,
                'unit': unit,
                'mag': mag,
                'day': urlDate,
                'time': time,
                'position': position,
            }
            url = addeUrlFormat % formatValues
            print url
            adl = AreaDirectoryList(url)
            dirs = adl.getSortedDirs()
            for areaDirectory in dirs[0]:
                areaDirectories.append(areaDirectory)
            
    temp = _AreaDirectoryList()
    for i, d in enumerate(areaDirectories):
        # print i, d.getBands(), d.getSensorType(), d.getCenterLatitude(), d.getCenterLongitude()
        print i, d
        nominalTime = d.getNominalTime()
        tempDay = dateFormat.format(nominalTime, StringBuffer(), FieldPosition(0)).toString()
        tempTime = timeFormat.format(nominalTime, StringBuffer(), FieldPosition(0)).toString()
        
        tempBand = list(d.getBands())
        if len(tempBand) == 1:
            tempBand = tempBand[0]
        else:
            # raise Exception
            pass
            
        dt = {
            'server': server,
            'dataset': dataset,
            'descriptor': descriptor,
            'band': tempBand,
            'debug': debug,
            'accounting': accounting,
            'day': tempDay,
            'time': (tempTime, tempTime),
            'coordinateSystem': CoordinateSystems.AREA,
            'location': (d.getLines(), d.getElements()),
            
            
        }
        temp.append(dt)
    return temp