def space_events(lon=None, lat=None, limit=None, date=None):
    '''
    
    lat & lon expect decimal latitude and longitude values. (Required)
    elevation assumes meters. (Optional)
    limit assumes an integer. Default is 5. (Optional)
    date expects an ISO 8601 formatted date. (Optional)
    '''

    base_url = 'http://api.predictthesky.org/?'

    if not lon or not lat:
        raise ValueError(
            "space_events endpoint expects lat and lon, type has to be float. Call the method with keyword args. Ex : lon=100.75, lat=1.5"
        )
    else:
        try:
            validate_float(lon, lat)
            # Floats are entered/displayed as decimal numbers, but your computer
            # (in fact, your standard C library) stores them as binary.
            # You get some side effects from this transition:
            # >>> print len(repr(0.1))
            # 19
            # >>> print repr(0.1)
            # 0.10000000000000001
            # Thus using decimal to str transition is more reliant
            lon = decimal.Decimal(lon)
            lat = decimal.Decimal(lat)
            base_url += "lon=" + str(lon) + "&" + "lat=" + str(lat)
        except:
            raise ValueError(
                "space_events endpoint expects lat and lon, type has to be float. Call the method with keyword args. Ex : lon=100.75, lat=1.5"
            )

    if date:
        try:
            validate_iso8601(date)
            base_url += "&" + 'date=' + date
        except:
            raise ValueError(
                "Your date input is not in iso8601 format. ex: 2014-01-01T23:59:59"
            )

    if limit:
        if not isinstance(limit, int):
            logger.error(
                "The limit arg you provided is not the type of int, ignoring it"
            )
        base_url += "&" + "limit=" + str(limit)

    return dispatch_http_get(base_url)
Beispiel #2
0
def space_events(lon=None, lat=None, limit=None, date=None):
    '''
    
    lat & lon expect decimal latitude and longitude values. (Required)
    elevation assumes meters. (Optional)
    limit assumes an integer. Default is 5. (Optional)
    date expects an ISO 8601 formatted date. (Optional)
    '''

    base_url = 'http://api.predictthesky.org/?'

    if not lon or not lat:
        raise ValueError(
            "space_events endpoint expects lat and lon, type has to be float. Call the method with keyword args. Ex : lon=100.75, lat=1.5")
    else:
        try:
            validate_float(lon, lat)
            # Floats are entered/displayed as decimal numbers, but your computer 
            # (in fact, your standard C library) stores them as binary. 
            # You get some side effects from this transition:
            # >>> print len(repr(0.1))
            # 19
            # >>> print repr(0.1)
            # 0.10000000000000001
            # Thus using decimal to str transition is more reliant
            lon = decimal.Decimal(lon)
            lat = decimal.Decimal(lat)
            base_url += "lon=" + str(lon) + "&" + "lat=" + str(lat)
        except:
            raise ValueError(
                "space_events endpoint expects lat and lon, type has to be float. Call the method with keyword args. Ex : lon=100.75, lat=1.5")

    if date:
        try:
            validate_iso8601(date)
            base_url += "&" + 'date=' + date
        except:
            raise ValueError(
                "Your date input is not in iso8601 format. ex: 2014-01-01T23:59:59")

    if limit:
        if not isinstance(limit, int):
            logger.error(
                "The limit arg you provided is not the type of int, ignoring it")
        base_url += "&" + "limit=" + str(limit)

    return dispatch_http_get(base_url)
Beispiel #3
0
def getjp2image(date,
                sourceId=None,
                observatory=None,
                instrument=None,
                detector=None,
                measurement=None):
    '''
    Helioviewer.org and JHelioviewer operate off of JPEG2000 formatted image data generated from science-quality FITS files. Use the APIs below to interact directly with these intermediary JPEG2000 files.
    
    Download a JP2 image for the specified datasource that is the closest match in time to the `date` requested.

    Either `sourceId` must be specified, or the combination of `observatory`, `instrument`, `detector`, and `measurement`.

    Request Parameters:

    Parameter	Required	Type	Example	Description
    date	Required	string	2014-01-01T23:59:59Z	Desired date/time of the JP2 image. ISO 8601 combined UTC date and time UTC format.
    sourceId	Optional	number	14	Unique image datasource identifier.
    observatory	Optional	string	SDO	Observatory name.
    instrument	Optional	string	AIA	Instrument name.
    detector	Optional	string	AIA	Detector name.
    measurement	Optional	string	335	Measurement name.
    jpip	Optional	boolean	false	Optionally return a JPIP URI instead of the binary data of the image itself.
    json	Optional	boolean	false	Optionally return a JSON object.


    EXAMPLE: http://helioviewer.org/api/v1/getJP2Image/?date=2014-01-01T23:59:59Z&sourceId=14&jpip=true
    '''

    base_url = 'http://helioviewer.org/api/v1/getJP2Image/?'
    req_url = ''

    try:
        validate_iso8601(date)
        if not date[-1:] == 'Z':
            date += 'Z'
        base_url += 'date=' + date
    except:
        raise ValueError(
            "Your date input is not in iso8601 format. ex: 2014-01-01T23:59:59")

    if sourceId:
        if not isinstance(sourceId, int):
            logger.error("The sourceId argument should be an int, ignoring it")
        else:
            base_url += "sourceId=" + str(sourceId) + "&"

    if observatory:
        if not isinstance(observatory, str):
            logger.error(
                "The observatory argument should be a str, ignoring it")
        else:
            base_url += "observatory=" + observatory + "&"

    if instrument:
        if not isinstance(instrument, str):
            logger.error(
                "The instrument argument should be a str, ignoring it")
        else:
            base_url += "instrument=" + instrument + "&"
    if detector:
        if not isinstance(detector, str):
            logger.error("The detector argument should be a str, ignoring it")
        else:
            base_url += "detector=" + detector + "&"

    if measurement:
        if not isinstance(measurement, str):
            logger.error(
                "The measurement argument should be a str, ignoring it")
        else:
            base_url += "measurement=" + detector + "&"

    req_url += base_url + "jpip=true"

    return dispatch_http_get(req_url)
Beispiel #4
0
def getjp2image(date,
                sourceId=None,
                observatory=None,
                instrument=None,
                detector=None,
                measurement=None):
    '''
    Helioviewer.org and JHelioviewer operate off of JPEG2000 formatted image data generated from science-quality FITS files. Use the APIs below to interact directly with these intermediary JPEG2000 files.
    
    Download a JP2 image for the specified datasource that is the closest match in time to the `date` requested.

    Either `sourceId` must be specified, or the combination of `observatory`, `instrument`, `detector`, and `measurement`.

    Request Parameters:

    Parameter	Required	Type	Example	Description
    date	Required	string	2014-01-01T23:59:59Z	Desired date/time of the JP2 image. ISO 8601 combined UTC date and time UTC format.
    sourceId	Optional	number	14	Unique image datasource identifier.
    observatory	Optional	string	SDO	Observatory name.
    instrument	Optional	string	AIA	Instrument name.
    detector	Optional	string	AIA	Detector name.
    measurement	Optional	string	335	Measurement name.
    jpip	Optional	boolean	false	Optionally return a JPIP URI instead of the binary data of the image itself.
    json	Optional	boolean	false	Optionally return a JSON object.


    EXAMPLE: http://helioviewer.org/api/v1/getJP2Image/?date=2014-01-01T23:59:59Z&sourceId=14&jpip=true
    '''

    base_url = 'http://helioviewer.org/api/v1/getJP2Image/?'
    req_url = ''

    try:
        validate_iso8601(date)
        if not date[-1:] == 'Z':
            date += 'Z'
        base_url += 'date=' + date
    except:
        raise ValueError(
            "Your date input is not in iso8601 format. ex: 2014-01-01T23:59:59"
        )

    if sourceId:
        if not isinstance(sourceId, int):
            logger.error("The sourceId argument should be an int, ignoring it")
        else:
            base_url += "sourceId=" + str(sourceId) + "&"

    if observatory:
        if not isinstance(observatory, str):
            logger.error(
                "The observatory argument should be a str, ignoring it")
        else:
            base_url += "observatory=" + observatory + "&"

    if instrument:
        if not isinstance(instrument, str):
            logger.error(
                "The instrument argument should be a str, ignoring it")
        else:
            base_url += "instrument=" + instrument + "&"
    if detector:
        if not isinstance(detector, str):
            logger.error("The detector argument should be a str, ignoring it")
        else:
            base_url += "detector=" + detector + "&"

    if measurement:
        if not isinstance(measurement, str):
            logger.error(
                "The measurement argument should be a str, ignoring it")
        else:
            base_url += "measurement=" + detector + "&"

    req_url += base_url + "jpip=true"

    return dispatch_http_get(req_url)