コード例 #1
0
def get_erp_final_target(**kwargs):
    """ Final Earth Rotation Parameters (ERP) files in from COD

      kwargs that matter:
      span='daily' for daily ERP's or 'weekly' for weekly ERP file
      code_dir='code' to download files from CODE_URL/CODE/yyyy or 'bswuser52' 
                to download from CODE_URL/BSWUSER52/ORB/yyyy
      acid='cod' Optional but if given must be cod
      type='final' Optional but if given must be 'final'
      format='bernese' Optional but if given must be 'bernese'
      To provide a date, use either:
        * pydt=datetime.datetime(...) or 
        * year=... and doy=...

      Default values:
      kwargs['span'] = daily

      CODwwww7.ERP.Z    Weekly CODE final ERP files as from week 0978 (*)
      CODyyddd.ERP.Z    Daily CODE final ERP files as from week 1706 (*)
      CODwwwwd.ERP.Z    CODE final ERPs belonging to the final orbits (+)
      CODwwww7.ERP.Z    Collection of the 7 daily COD-ERP solutions of the 
                        week (+)

      type=final
                        |span=daily                          | span=weekly                        |
      ------------------+------------------------------------+------------------------------------+
      code_dir=code     | /CODE/yyyy/CODwwwwd.ERP.Z          | /CODE/yyyy/CODwwww7.ERP.Z          |
      code_dir=bswuser52| /BSWUSER52/ORB/yyyy/CODyyddd.ERP.Z | /BSWUSER52/ORB/yyyy/CODwwww7.ERP.Z |


      (*) under /BSWUSER52/ORB/yyyy
      (+) under /CODE/yyyy

      I cannot find any difference between CODwwww7.ERP.Z Vs CODwwww7.ERP.Z,
      and CODyyddd.ERP.Z Vs CODwwwwd.ERP.Z. Hence, we add an optional argument
      'code_dir' which can take the values 'bswuser52' and 'code' and decides 
      which of the two options will be used (aka the remote ftp directory). By 
      default, the value defaults to code_dir=code

  """
    if 'format' in kwargs and kwargs['format'] not in ['bernese']:
        raise ArgumentError('[ERROR] code::get_erp_final Invalid format',
                            'format', **kwargs)
    if 'acid' in kwargs and kwargs['acid'] not in ['cod']:
        raise ArgumentError('[ERROR] code::get_erp_final Invalid acid', 'acid',
                            **kwargs)
    if 'type' in kwargs and kwargs['type'] != 'final':
        raise ArgumentError('[ERROR] code::get_erp_final Invalid type', 'type',
                            **kwargs)
    if 'span' in kwargs and kwargs['span'] not in ['daily', 'weekly']:
        raise ArgumentError('[ERROR] code::get_erp_final Invalid span', 'span',
                            **kwargs)
    if 'code_dir' in kwargs and kwargs['code_dir'] not in [
            'bswuser52', 'code'
    ]:
        raise ArgumentError('[ERROR] code::get_erp_final Invalid code_dir',
                            'code_dir', **kwargs)

    if 'span' not in kwargs:
        kwargs['span'] = 'daily'
    if 'code_dir' not in kwargs:
        kwargs['code_dir'] = 'code'

    pydt = _date(**kwargs)  ## this may throw
    yy, ddd = pydt2yydoy(pydt)
    week, sow = pydt2gps(pydt)

    if kwargs['code_dir'] == 'code':
        url_dir = '{:}/{:}'.format('CODE', pydt.strftime('%Y'))
    else:
        url_dir = '{:}/{:}/{:}'.format('BSWUSER52', 'ORB', pydt.strftime('%Y'))

    acn = 'COD'
    frmt = 'ERP'
    if kwargs['span'] == 'weekly':
        sdate = '{:04d}{:1d}'.format(week, 7)
    else:
        if kwargs['code_dir'] == 'code':
            sdate = '{:04d}{:01d}'.format(week, sow2dow(sow))
        else:
            sdate = '{:02d}{:03d}'.format(yy, ddd)

    erp = '{:}{:}.{:}.Z'.format(acn, sdate, frmt)
    target = '{:}/{:}/{:}'.format(CODE_URL, url_dir, erp)
    return target
コード例 #2
0
def get_dcb_final_target(**kwargs):
    """ Final Differential Code Bias (DCB) in DCB format from COD

      *type=final
        span=daily, obs=p1p2             | BSWUSER52/ORB/yyyy/CODyyddd.DCB.Z
        span=monthly, obs=p1c1           | CODE/yyyy/P1C1yymm.DCB.Z
        span=monthly, obs=p1p2           | CODE/yyyy/P1P2yymm.DCB.Z
        span=monthly, obs=p1p2all        | CODE/yyyy/P1P2yymm_ALL.DCB.Z
        span=monthly, obs=p1c1rnx        | CODE/yyyy/P1C1yymm_RINEX.DCB
        span=monthly, obs=p2c2rnx        | CODE/yyyy/P2C2yymm_RINEX.DCB

      kwargs that matter:
      format='dcb' Optional but if given it must be dcb
      type='final' Optional but if given must be 'final'
      acid='cod' Optional but if it exists it must be 'cod'
      span= daily or monthly
      obs= Choose from above table
      To provide a date, use either:
        * pydt=datetime.datetime(...) or 
        * year=... and doy=...

      Default values:
      kwargs['format'] = dcb
      kwargs['acid'] = cod
      kwargs['type'] = final
      kwargs['span'] = monthly
      kwargs['obs'] = p1c1

  """
    if 'format' in kwargs and kwargs['format'] not in ['dcb']:
        raise ArgumentError('[ERROR] code::get_dcb_final Invalid format',
                            'format', **kwargs)
    if 'acid' in kwargs and kwargs['acid'] not in ['cod']:
        raise ArgumentError('[ERROR] code::get_dcb_final Invalid acid', 'acid',
                            **kwargs)
    if 'type' in kwargs and kwargs['type'] != 'final':
        raise ArgumentError('[ERROR] code::get_dcb_final Invalid type', 'type',
                            **kwargs)
    if 'span' in kwargs and kwargs['span'] not in ['monthly', 'daily']:
        raise ArgumentError('[ERROR] code::get_dcb_final Invalid span', 'span',
                            **kwargs)
    if 'obs' in kwargs and kwargs['obs'] not in [
            'p1p2', 'p1c1', 'p1p2all', 'p1c1rnx', 'p2c2rnx'
    ]:
        raise ArgumentError('[ERROR] code::get_dcb_final Invalid obs', 'obs',
                            **kwargs)

    if 'format' not in kwargs:
        kwargs['format'] = 'dcb'
    if 'type' not in kwargs:
        kwargs['type'] = 'final'
    if 'acid' not in kwargs:
        kwargs['acid'] = 'cod'
    if 'span' not in kwargs:
        kwargs['span'] = 'monthly'
    if 'obs' not in kwargs:
        kwargs['obs'] = 'p1c1'

    pydt = _date(**kwargs)  ## this may throw
    yy, ddd = pydt2yydoy(pydt)
    mm, yyyy = pydt.strftime('%m'), pydt.strftime('%Y')

    spec = ''
    if kwargs['span'] == 'daily' and kwargs['obs'] == 'p1p2':
        acn = 'COD'
        sdate = '{:02d}{:03d}'.format(yy, ddd)
        url_dir = 'BSWUSER52/ORB/{:}'.format(yyyy)
        frmt = 'DCB.Z'
    elif kwargs['span'] == 'monthly':
        sdate = '{:02d}{:}'.format(yy, mm)
        url_dir = 'CODE/{:}'.format(yyyy)
        if kwargs['obs'] == 'p1c1':
            acn = 'P1C1'
            frmt = 'DCB.Z'
        elif kwargs['obs'] == 'p1p2':
            acn = 'P1P2'
            frmt = 'DCB.Z'
        elif kwargs['obs'] == 'p1p2all':
            acn = 'P1P2'
            spec = '_ALL'
            frmt = 'DCB.Z'
        elif kwargs['obs'] == 'p1c1rnx':
            acn = 'P1C1'
            spec = '_RINEX'
            frmt = 'DCB.Z'
        elif kwargs['obs'] == 'p2c2rnx':
            acn = 'P2C2'
            spec = '_RINEX'
            frmt = 'DCB.Z'
    try:
        dcb = '{:}{:}{:}.{:}'.format(acn, sdate, spec, frmt)
        target = '{:}/{:}/{:}'.format(CODE_URL, url_dir, dcb)
    except:
        msg = '[ERROR] code::get_dcb_final Failed to formulate DCB file'
        raise RuntimeError(msg)
    return target
コード例 #3
0
ファイル: codeion.py プロジェクト: DSOlab/autobern
def get_ion_rapid_target(**kwargs):
    """ Rapid or Ultra-rapid ionosphere information in IONEX or Bernese format 
      from COD

      CORGddd0.yyI.Z    CODE rapid ionosphere product, IONEX format
      COPGddd0.yyI.Z    CODE 1-day or 2-day ionosphere predictions,
                        in IONEX format
      CODwwwwd.ION_R    CODE rapid ionosphere product, Bernese format
      CODwwwwd.ION_P    CODE 1-day ionosphere predictions, Bernese format
      CODwwwwd.ION_P2   CODE 2-day ionosphere predictions, Bernese format
      CODwwwwd.ION_P5   CODE 5-day ionosphere predictions, Bernese format
      COD.ION_U         Last update of CODE rapid ionosphere product
                        (1 day) complemented with ionosphere predictions 
                        (2 days)

      kwargs that matter:
      format='ionex' or format='inx' to get the IONEX format.
      format='ion' or format='bernese' to get the Bernese format.
      acid='coe' to get the EUREF solution.
      To provide a date, use either:
        * pydt=datetime.datetime(...) or 
        * year=... and doy=...
  
      Default Values
      kwargs['format'] = 'bernese'
      kwargs['type'] = 'rapid'

      aka:
      kwargs         |format=ionex        | format=bernese      |
      ---------------+--------------------+---------------------+
      type=rapid     |CODE/CORGddd0.yyI.Z | CODE/CODwwwwd.ION_R |
      type=prediction|CODE/COPGddd0.yyI.Z | CODE/CODwwwwd.ION_P |
      type=current or|                    | CODE/COD.ION_U      |
      urapid or      |                    |
      ultra-rapid    |                    |
      type=p2        |                    | CODE/CODwwwwd.ION_P2|
      type=p5        |                    | CODE/CODwwwwd.ION_P5|

      TODO current should be an alias for urapid or ultra-rapid
  """
    if 'format' in kwargs and kwargs['format'] not in [
            'ionex', 'inx', 'ion', 'bernese'
    ]:
        raise ArgumentError('[ERROR] code::get_ion_rapid Invalid format',
                            'format', **kwargs)
    if 'type' in kwargs and kwargs['type'] not in [
            'rapid', 'prediction', 'current', 'p2', 'p5', 'urapid',
            'ultra-rapid'
    ]:
        raise ArgumentError('[ERROR] code::get_ion_rapid Invalid type', 'type',
                            **kwargs)

    if 'format' not in kwargs:
        kwargs['format'] = 'bernese'
    if 'type' in kwargs and kwargs['type'] in ['urapid', 'ultra-rapid']:
        kwargs['type'] = 'current'
    if 'type' not in kwargs:
        kwargs['type'] = 'rapid'

    if kwargs['type'] != 'current':
        pydt = _date(**kwargs)  ## this may throw
        yy, ddd = pydt2yydoy(pydt)

    if kwargs['format'] in ['ionex', 'inx']:
        sdate = '{:03d}0'.format(ddd)
        frmt = '{:}I.Z'.format(pydt.strftime("%y"))
        if 'type' in kwargs and kwargs['type'] == 'rapid':
            acn = 'CORG'
        elif 'type' in kwargs and kwargs['type'] == 'prediction':
            acn = 'COPG'
        else:
            raise RuntimeError(
                '[ERROR] code::get_ion_rapid invalid request (#1)')

    if kwargs['format'] in ['bernese', 'ion']:
        acn = 'COD'
        if kwargs['type'] == 'current':
            frmt = 'ION_U'
            sdate = ''
        else:
            week, sow = pydt2gps(pydt)
            sdate = '{:04d}{:1d}'.format(week, sow2dow(sow))
            if kwargs['type'] == 'rapid':
                frmt = 'ION_R'
            elif kwargs['type'] == 'prediction':
                frmt = 'ION_P'
            elif kwargs['type'] == 'p2':
                frmt = 'ION_P2'
            elif kwargs['type'] == 'p5':
                frmt = 'ION_P5'
            else:
                raise RuntimeError(
                    '[ERROR] code::get_ion_rapid invalid request (#2)')

    ion = '{:}{:}.{:}'.format(acn, sdate, frmt)
    target = '{:}/CODE/{:}'.format(CODE_URL, ion)
    return target
コード例 #4
0
def get_dcb_rapid_target(**kwargs):
    """ Rapid and Ultra-Rapid Differential Code Bias (DCB) in DCB format from 
      COD

       [1] type=rapid, span=daily, obs=p1p2        | BSWUSER52/ORB/yyyy/CORyyddd.DCB.Z
       [2] type=current, span=monthly, obs=p1c1    | P1C1.DCB (GPS sats only)
       [3] type=current, span=monthly, obs=p1p2    | P1P2.DCB
       [4] type=current, span=monthly, obs=p1p2all | P1P2_ALL.DCB
       [5] type=current, span=monthly, obs=p1p2gps | P1P2_GPS.DCB
       [6] type=current, span=monthly, obs=p1c1rnx | P1C1_RINEX.DCB
       [7] type=current, span=monthly, obs=p2c2rnx | P1C2_RINEX.DCB
       [8] type=current, span=monthly, obs=p1p2p1c1| CODE.DCB (merged [2] and [3])
       [9] type=current, span=monthly, obs=full    | CODE_FULL.DCB (merged [2], [3], [6] and [7])

      kwargs that matter:
      format='dcb' Optional but if given it must be dcb
      type=rapid or current; See table above
      acid='cod' Optional but if it exists it must be 'cod'
      span= daily or monthly
      obs= Choose from above table
      To provide a date if needed, use either:
        * pydt=datetime.datetime(...) or 
        * year=... and doy=...
      A date is needed only in case [1]

      Default values:
      kwargs['format'] = dcb
      kwargs['acid'] = cod
      kwargs['type'] = current
      kwargs['span'] = monthly
      kwargs['obs'] = full

  """
    if 'format' in kwargs and kwargs['format'] not in ['dcb']:
        raise ArgumentError('[ERROR] code::get_dcb_rapid Invalid format',
                            'format', **kwargs)
    if 'acid' in kwargs and kwargs['acid'] not in ['cod']:
        raise ArgumentError('[ERROR] code::get_dcb_rapid Invalid acid', 'acid',
                            **kwargs)
    if 'type' in kwargs and kwargs['type'] not in ['rapid', 'current']:
        raise ArgumentError('[ERROR] code::get_dcb_rapid Invalid type', 'type',
                            **kwargs)
    if 'span' in kwargs and kwargs['span'] not in ['monthly', 'daily']:
        raise ArgumentError('[ERROR] code::get_dcb_rapid Invalid span', 'span',
                            **kwargs)
    if 'obs' in kwargs and kwargs['obs'] not in [
            'p1p2', 'p1c1', 'p1p2all', 'p1p2gps', 'p1c1rnx', 'p1c2rnx',
            'p1p2p1c1', 'full'
    ]:
        raise ArgumentError('[ERROR] code::get_dcb_rapid Invalid obs', 'obs',
                            **kwargs)

    if 'format' not in kwargs:
        kwargs['format'] = 'dcb'
    if 'type' not in kwargs:
        kwargs['type'] = 'current'
    if 'acid' not in kwargs:
        kwargs['acid'] = 'cod'
    if 'span' not in kwargs:
        kwargs['span'] = 'monthly'
    if 'obs' not in kwargs:
        kwargs['obs'] = 'full'

    spec = ''
    if kwargs['type'] == 'rapid' and kwargs['span'] == 'daily' and kwargs[
            'obs'] == 'p1p2':
        pydt = _date(**kwargs)
        yy, ddd = pydt2yydoy(pydt)
        mm, yyyy = pydt.strftime('%m'), pydt.strftime('%Y')
        url_dir = 'BSWUSER52/ORB/{:}'.format(yyyy)
        acn = 'COR'
        sdate = '{:02d}{:03d}'.format(yy, ddd)
        frmt = 'DCB.Z'
    elif kwargs['type'] == 'current' and kwargs['span'] == 'monthly':
        url_dir = 'CODE'
        frmt = 'DCB'
        sdate = ''
        if kwargs['obs'] == 'p1c1':
            acn = 'P1C1'
        elif kwargs['obs'] == 'p1p2':
            acn = 'P1P2'
        elif kwargs['obs'] == 'p1p2all':
            acn = 'P1P2'
            spec = '_ALL'
        elif kwargs['obs'] == 'p1p2gps':
            acn = 'P1P2'
            spec = '_GPS'
        elif kwargs['obs'] == 'p1c1rnx':
            acn = 'P1C1'
            spec = '_RINEX'
        elif kwargs['obs'] == 'p1c2rnx':
            acn = 'P1C2'
            spec = '_RINEX'
        elif kwargs['obs'] == 'p1c2rnx':
            acn = 'CODE'
            spec = ''
        elif kwargs['obs'] == 'p1p2p1c1':
            acn = 'CODE'
            spec = ''
        elif kwargs['obs'] == 'full':
            acn = 'CODE'
            spec = '_FULL'
    try:
        dcb = '{:}{:}{:}.{:}'.format(acn, sdate, spec, frmt)
        target = '{:}/{:}/{:}'.format(CODE_URL, url_dir, dcb)
    except:
        msg = '[ERROR] code::get_dcb_rapid Failed to formulate DCB file'
        raise RuntimeError(msg)
    return target
コード例 #5
0
ファイル: codeion.py プロジェクト: DSOlab/autobern
def get_ion_final_target(**kwargs):
    """ Final ionosphere information in IONEX or Bernese format from COD

      kwargs that matter:
      format='ionex' or format='inx' to get the IONEX format.
      format='ion' or format='bernese' to get the Bernese format.
      acid='coe' to get the EUREF solution.
      type='final' Optional but if given must be 'final'
      To provide a date, use either:
        * pydt=datetime.datetime(...) or 
        * year=... and doy=...

      Default values:
      kwargs['format'] = bernese
      kwargs['acid'] = cod

      kwargs  |format=ionex                 | format=bernese               |
      --------+-----------------------------+------------------------------+
      acid=coe|BSWUSER52/ATM/yyyy/COEyyddd.INX.Z| BSWUSER52/ATM/yyyy/COEyyddd.ION.Z|
      acid=cod|CODE/yyyy/CODGddd0.yyI.Z     | CODE/yyyy/CODwwwwd.ION.Z     |
  """
    if 'format' in kwargs and kwargs['format'] not in [
            'ionex', 'inx', 'ion', 'bernese'
    ]:
        raise ArgumentError('[ERROR] code::get_ion_final Invalid format',
                            'format', **kwargs)
    if 'acid' in kwargs and kwargs['acid'] not in ['cod', 'coe']:
        raise ArgumentError('[ERROR] code::get_ion_final Invalid acid', 'acid',
                            **kwargs)
    if 'type' in kwargs and kwargs['type'] != 'final':
        raise ArgumentError('[ERROR] code::get_ion_final Invalid type', 'type',
                            **kwargs)

    if 'format' not in kwargs:
        kwargs['format'] = 'bernese'
    if 'acid' not in kwargs:
        kwargs['acid'] = 'cod'

    pydt = _date(**kwargs)  ## this may throw
    yy, ddd = pydt2yydoy(pydt)
    if kwargs['format'] in ['bernese', 'ion']:
        frmt = 'ION'
    else:
        if kwargs['acid'] == 'coe':
            frmt = 'INX'
        else:
            frmt = '{:02d}I'.format(yy)

    if kwargs['acid'] == 'coe':
        url_dir = 'BSWUSER52/ATM/{:}'.format(pydt.strftime("%Y"))
        acn = 'COE'
        sdate = '{:02d}{:03d}'.format(yy, ddd)
    else:
        url_dir = 'CODE/{:}'.format(pydt.strftime("%Y"))
        if kwargs['format'] in ['bernese', 'ion']:
            acn = 'COD'
            week, sow = pydt2gps(pydt)
            sdate = '{:04d}{:01d}'.format(week, sow2dow(sow))
        else:
            acn = 'CODG'
            sdate = '{:03d}0'.format(ddd)

    ion = '{:}{:}.{:}.Z'.format(acn, sdate, frmt)
    target = '{:}/{:}/{:}'.format(CODE_URL, url_dir, ion)
    return target