コード例 #1
0
def gebco2srf(gebco_file, abval, beval, axp, sph2ll, ll2sph, ll2utm, utm2ll):
    """
    """
    if not path.exists(gebco_file):
        raise TelemacException(\
                '... the provided GEBCO file does '
                'not seem to exist: {}\n\n'.format(gebco_file))
    head, _ = path.splitext(gebco_file)

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Download the GEBCO file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\n'+72*'~'+'\n')
    print('\nLoading the GEBCO file\n')
    gebco2slf = Gebco(gebco_file, (abval, beval))

    gebco2slf.meshx = gebco2slf.meshx + float(axp)
    if sph2ll != None:
        radius = 6371000.
        long0, lat0 = sph2ll.split(":")
        long0 = np.deg2rad(float(long0))
        lat0 = np.deg2rad(float(lat0))
        const = np.tan(lat0/2. + np.pi/4.)
        gebco2slf.meshx = np.rad2deg(gebco2slf.meshx/radius + long0)
        tmp = np.arctan(const*np.exp(gebco2slf.meshy/radius))
        gebco2slf.meshy = np.rad2deg(2.*tmp - np.pi/2.)
    if ll2sph != None:
        radius = 6371000.
        long0, lat0 = ll2sph.split(":")
        long0 = np.deg2rad(float(long0))
        lat0 = np.deg2rad(float(lat0))
        gebco2slf.meshx = radius * (np.deg2rad(gebco2slf.meshx) - long0)
        gebco2slf.meshy = \
           radius * (np.log(np.tan(np.deg2rad(gebco2slf.meshy)/2. + np.pi/4.)) \
                     - np.log(np.tan(lat0/2. + np.pi/4.)))
    if ll2utm != None:
        zone = int(ll2utm)
        gebco2slf.meshx, gebco2slf.meshy, zone = \
                  utm.from_lat_long(gebco2slf.meshx, gebco2slf.meshy, zone)
    if utm2ll != None:
        zone = int(utm2ll)
        gebco2slf.meshx, gebco2slf.meshy = \
                  utm.to_lat_long(gebco2slf.meshx, gebco2slf.meshy, zone)

# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
# ~~~~ Convert to SELAFIN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\n'+72*'~'+'\n')
    print('\nConverting into SELAFIN\n')
    gebco2slf.put_content(head+'.slf')
コード例 #2
0
def generate_atm(geo_file, slf_file, atm_file, ll2utm):

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ slf new mesh ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    if not path.exists(geo_file):
        raise TelemacException(\
            '... the provided geo_file does not '
            'seem to exist: {}\n\n'.format(geo_file))

# Find corresponding (x,y) in corresponding new mesh
    print('   +> getting hold of the GEO file')
    geo = Selafin(geo_file)
    if ll2utm != None:
        zone = int(ll2utm)
        x, y = to_lat_long(geo.meshx, geo.meshy, zone)
    else:
        x = geo.meshx
        y = geo.meshy
    xys = np.vstack((x, y)).T

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ slf existing res ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    if not path.exists(slf_file):
        raise TelemacException(\
                '... the provided slf_file does not seem to exist: '
                '{}\n\n'.format(slf_file))
    slf = Selafin(slf_file)
    slf.set_kd_tree()
    slf.set_mpl_tri()

    print('   +> support extraction')
    # Extract triangles and weights in 2D
    support2d = []
    ibar = 0
    pbar = ProgressBar(maxval=len(xys)).start()
    for xyi in xys:
        support2d.append(
            xys_locate_mesh(xyi, slf.ikle2, slf.meshx, slf.meshy, slf.tree,
                            slf.neighbours))
        ibar += 1
        pbar.update(ibar)
    pbar.finish()
    # Extract support in 3D
    support3d = list(zip(support2d, len(xys) * [range(slf.nplan)]))

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ writes ATM header ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    atm = Selafin('')
    atm.fole = {}
    atm.fole.update({'hook': open(atm_file, 'wb')})
    atm.fole.update({'name': atm_file})
    atm.fole.update({'endian': ">"})  # big endian
    atm.fole.update({'float': ('f', 4)})  # single precision

    # Meta data and variable names
    atm.title = ''
    atm.varnames = []
    atm.varunits = []
    if 'WIND VELOCITY U ' in slf.varnames:
        atm.varnames.append('WIND VELOCITY U ')
        atm.varunits.append('M/S             ')
    if 'WIND VELOCITY V ' in slf.varnames:
        atm.varnames.append('WIND VELOCITY V ')
        atm.varunits.append('M/S             ')
    if 'SURFACE PRESSURE' in slf.varnames:
        atm.varnames.append('SURFACE PRESSURE')
        atm.varunits.append('UI              ')
    if 'AIR TEMPERATURE ' in slf.varnames:
        atm.varnames.append('AIR TEMPERATURE ')
        atm.varunits.append('DEGREES         ')
    if not atm.varnames:
        print('There are no meteorological variables to convert!')
        raise
    atm.nbv1 = len(atm.varnames)
    atm.nvar = atm.nbv1
    atm.varindex = range(atm.nvar)

    # Sizes and mesh connectivity
    atm.nplan = slf.nplan  # it should be 2d but why the heack not ...
    atm.ndp2 = slf.ndp2
    atm.ndp3 = slf.ndp3
    atm.npoin2 = geo.npoin2
    atm.npoin3 = geo.npoin2 * atm.nplan
    atm.nelem2 = geo.nelem2

    print('   +> setting connectivity')
    if atm.nplan > 1:
        atm.nelem3 = geo.nelem2 * (atm.nplan - 1)
        atm.ikle2 = geo.ikle2
        atm.ikle3 = \
            np.repeat(geo.npoin2*np.arange(atm.nplan-1),
                      geo.nelem2*atm.ndp3)\
              .reshape((geo.nelem2*(atm.nplan-1), atm.ndp3)) + \
            np.tile(np.add(np.tile(geo.ikle2, 2),
                           np.repeat(geo.npoin2*np.arange(2),
                                     geo.ndp2)),
                    (atm.nplan-1, 1))
        atm.ipob2 = geo.ipob2
        atm.ipob3 = np.ravel(np.add(np.repeat(geo.ipob2, atm.nplan)\
                                      .reshape((geo.npoin2, atm.nplan)),
                                    geo.npoin2*np.arange(atm.nplan)).T)
    else:
        atm.nelem3 = geo.nelem2
        atm.ikle2 = geo.ikle2
        atm.ikle3 = geo.ikle3
        atm.ipob2 = geo.ipob2
        atm.ipob3 = geo.ipob3
    atm.iparam = [0, 0, 0, 0, 0, 0, 0, np.count_nonzero(atm.ipob2), 0, 1]

    # Mesh coordinates
    atm.meshx = geo.meshx
    atm.meshy = geo.meshy

    print('   +> writing header')
    # Write header
    atm.append_header_slf()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ writes ATM core ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    print('   +> setting variables')
    # TIME and DATE extraction
    atm.datetime = slf.datetime
    atm.tags['times'] = slf.tags['times']
    # VARIABLE extraction
    vrs = subset_variables_slf(';'.join([var + ': ' for var in atm.varnames]),
                               slf.varnames)

    # Read / Write data, one time step at a time to support large files
    pbar = ProgressBar(maxval=len(slf.tags['times'])).start()
    for time in range(len(slf.tags['times'])):

        data = get_value_history_slf(slf.file, slf.tags, [time], support3d,
                                     slf.nvar, slf.npoin3, slf.nplan, vrs)
        # special cases ?
        atm.append_core_time_slf(time)
        atm.append_core_vars_slf(np.reshape(np.transpose(\
                  np.reshape(np.ravel(data),
                             (atm.nvar, atm.npoin2, atm.nplan)),
                  (0, 2, 1)),
                                            (atm.nvar, atm.npoin3)))
        pbar.update(time)
    pbar.finish()

    # Close atm_file
    atm.fole['hook'].close()
コード例 #3
0
def tesselate(options):
    """
    Generate a mesh from a polygon
    """
    if not options.freplace:
        if len(options.args) != 2:
            raise TelemacException(\
                    '\nThe code "tessellate" here '
                    'requires one i2s/i3s file and '
                    'one output slf file\n')
        i3s_file = options.args[0]
        out_file = options.args[1]
    else:
        if len(options.args) != 1:
            raise TelemacException(\
                    '\nThe code "tessellate" here '
                    'requires one i2s/i3s file\n')
        i3s_file = options.args[0]
        head, _ = path.splitext(i3s_file)
        out_file = head+'.slf'

    i3s_file = path.realpath(i3s_file)
    if not path.exists(i3s_file):
        raise TelemacException(\
                '\nCould not find '
                'the file named: {}'.format(i3s_file))

    print('\n\nTessellating ' + path.basename(i3s_file) + ' within ' + \
            path.dirname(i3s_file) + '\n'+'~'*72+'\n')
    i2s = InS(i3s_file)
    ikle2, ipob2, meshx, meshy = tessellate_poly(i2s, debug=True)

    print('\n\nWriting down the Selafin file ' + \
            path.basename(out_file) + '\n'+'~'*72+'\n')
    slf = Selafin('')
    slf.title = ''
    slf.nplan = 1
    slf.ndp2 = 3
    slf.ndp3 = 3
    slf.nbv1 = 1
    slf.nvar = 1
    slf.varindex = 1
    slf.varnames = ['BOTTOM          ']
    slf.varunits = ['M               ']
    slf.ikle2 = ikle2
    slf.ikle3 = slf.ikle2
    slf.meshx = meshx
    slf.meshy = meshy
    slf.npoin2 = i2s.npoin
    slf.npoin3 = slf.npoin2
    slf.nelem2 = len(slf.ikle2)/slf.ndp3
    slf.nelem3 = slf.nelem2
    slf.iparam = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0]
    slf.ipob2 = ipob2
    slf.ipob3 = slf.ipob2
    slf.fole = {'hook':open(out_file, 'wb'), 'endian':">",
                'float':('f', 4), 'name':out_file}
    slf.tags['times'] = [1]
    if options.sph2ll != None:
        radius = 6371000.
        long0, lat0 = options.sph2ll.split(":")
        long0 = np.deg2rad(float(long0))
        lat0 = np.deg2rad(float(lat0))
        const = np.tan(lat0/2. + np.pi/4.)
        slf.meshx = np.rad2deg(slf.meshx/radius + long0)
        slf.meshy = np.rad2deg(2.*np.arctan(const*np.exp(slf.meshy/radius)) \
                                      - np.pi/2.)
    if options.ll2sph != None:
        radius = 6371000.
        long0, lat0 = options.ll2sph.split(":")
        long0 = np.deg2rad(float(long0))
        lat0 = np.deg2rad(float(lat0))
        slf.meshx = radius * (np.deg2rad(slf.meshx) - long0)
        slf.meshy = radius * \
                  (np.log(np.tan(np.deg2rad(slf.meshy)/2. + np.pi/4.)) \
                                      - np.log(np.tan(lat0/2. + np.pi/4.)))
    if options.ll2utm != None:
        zone = int(options.ll2utm)
        slf.meshx, slf.meshy, zone = utm.from_lat_long(slf.meshx, slf.meshy,
                                                       zone)
    if options.utm2ll != None:
        zone = int(options.utm2ll)
        slf.meshx, slf.meshy = utm.to_lat_long(slf.meshx, slf.meshy, zone)
    slf.append_header_slf()
    slf.append_core_time_slf(0)
    slf.append_core_vars_slf([np.zeros(slf.npoin2)])
    slf.fole['hook'].close()
コード例 #4
0
def main():
    """ Main function of convertToSPE """

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Dependencies towards other modules ~~~~~~~~~~~~~~~~~~~~~~~~~~
    from argparse import ArgumentParser, RawDescriptionHelpFormatter
    from data_manip.formats.selafin import Selafin
    from data_manip.formats.conlim import Conlim
    from pretel.meshes import xys_locate_mesh

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Reads config file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nInterpreting command line options\n' + '~' * 72 + '\n')
    parser = ArgumentParser(\
        formatter_class=RawDescriptionHelpFormatter,
        description=('''\n
A script to map spectral outter model results, stored as SELAFIN files, onto the
    spatially and time varying boundary of a spatially contained SELAFIN file
    of your choosing (your MESH).
        '''),
        usage=' (--help for help)\n---------\n       => '\
                ' %(prog)s  open-bound.cli open-bound.slf in-outer-geo.slf '\
                'in-outer-spec.slf out-bound.slf \n---------')
    parser.add_argument(\
        "--ll2utm", dest="ll2utm", default=None,
        help="assume outer file is in lat-long and open-bound file in UTM")
    parser.add_argument("args", default='', nargs=5)
    options = parser.parse_args()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ cli+slf new mesh ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cli_file = options.args[0]
    if not path.exists(cli_file):
        raise TelemacException(\
                '... the provided cli_file does not seem '
                'to exist: {}\n\n'.format(cli_file))
    geo_file = options.args[1]
    if not path.exists(geo_file):
        raise TelemacException(\
                '... the provided geo_file does not seem to exist: '
                '{}\n\n'.format(geo_file))

    # Read the new CLI file to get boundary node numbers
    print('   +> getting hold of the CONLIM file and of its liquid boundaries')
    cli = Conlim(cli_file)
    # Keeping only open boundary nodes
    bor = np.extract(cli.bor['lih'] != 2, cli.bor['n'])

    # Find corresponding (x,y) in corresponding new mesh
    print('   +> getting hold of the GEO file and of its bathymetry')
    geo = Selafin(geo_file)
    if options.ll2utm != None:
        zone = int(options.ll2utm)
        x, y = to_lat_long(geo.meshx[bor - 1], geo.meshy[bor - 1], zone)
    else:
        x = geo.meshx[bor - 1]
        y = geo.meshy[bor - 1]
    xys = np.vstack((x, y)).T

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ slf+spe existing res ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    slf_file = options.args[2]
    if not path.exists(slf_file):
        raise TelemacException(\
                '... the provided slf_file does not seem to exist: '
                '{}\n\n'.format(slf_file))
    slf = Selafin(slf_file)
    slf.set_kd_tree()
    slf.set_mpl_tri()
    spe_file = options.args[3]
    if not path.exists(spe_file):
        raise TelemacException(\
                '... the provided slf_file does not seem to exist: '
                '{}\n\n'.format(spe_file))
    spe = Selafin(spe_file)

    print('   +> support extraction')
    # Extract triangles and weigths in 2D
    support2d = []
    ibar = 0
    pbar = ProgressBar(maxval=len(xys)).start()
    for xyi in xys:
        support2d.append(
            xys_locate_mesh(xyi, slf.ikle2, slf.meshx, slf.meshy, slf.tree,
                            slf.neighbours))
        ibar += 1
        pbar.update(ibar)
    pbar.finish()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ writes BND header ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    bnd_file = options.args[4]
    bnd = Selafin('')
    bnd.fole = {}
    bnd.fole.update({'hook': open(bnd_file, 'wb')})
    bnd.fole.update({'name': bnd_file})
    bnd.fole.update({'endian': ">"})  # big endian
    bnd.fole.update({'float': ('f', 4)})  # single precision

    # Meta data and variable names
    bnd.title = spe.title
    # spectrum for new locations / nodes
    for i in range(len(bor)):
        bnd.varnames.append(('F'+('00'+str(i))[-2:]+' PT2D'+('000000'+\
                                  str(bor[i]))[-6:]+'                ')[:16])
        bnd.varunits.append('UI              ')
    bnd.nbv1 = len(bnd.varnames)
    bnd.nvar = bnd.nbv1
    bnd.varindex = range(bnd.nvar)

    # sizes and mesh connectivity / spectrum
    bnd.nplan = spe.nplan
    bnd.ndp2 = spe.ndp2
    bnd.ndp3 = bnd.ndp2
    bnd.npoin2 = spe.npoin2
    bnd.npoin3 = spe.npoin3
    bnd.iparam = spe.iparam
    bnd.ipob2 = spe.ipob2
    bnd.ikle2 = spe.ikle2
    # Last few numbers
    bnd.nelem2 = len(bnd.ikle2)
    bnd.nelem3 = bnd.nelem2
    bnd.ipob3 = bnd.ipob2
    bnd.ikle3 = bnd.ikle2
    # Mesh coordinates
    bnd.meshx = spe.meshx
    bnd.meshy = spe.meshy

    print('   +> writing header')
    # Write header
    bnd.append_header_slf()

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ writes BND core ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    print('   +> setting variables')
    # TIME and DATE extraction
    bnd.datetime = spe.datetime
    bnd.tags['times'] = spe.tags['times']

    # pointer initialisation
    f = spe.file['hook']
    endian = spe.file['endian']
    ftype, fsize = spe.file['float']

    # Identofy variables (required for support2d geo-locations)
    specloc = []
    for n, _ in support2d:
        specloc.extend(n)
    vars_indexes = np.unique(specloc)
    if fsize == 4:
        z = np.zeros((len(vars_indexes), spe.npoin2), dtype=np.float32)
        data = np.zeros(spe.npoin2, dtype=np.float32)
    else:
        z = np.zeros((len(vars_indexes), spe.npoin2), dtype=np.float64)
        data = np.zeros(spe.npoin2, dtype=np.float64)

    # Read / Write data, one time step at a time to support large files
    print('   +> reading / writing variables')
    pbar = ProgressBar(maxval=len(spe.tags['times'])).start()
    for itime in range(len(spe.tags['times'])):
        f.seek(
            spe.tags['cores'][itime])  # [itime] is the frame to be extracted
        f.seek(4 + fsize + 4, 1)  # the file pointer is initialised
        bnd.append_core_time_slf(itime)

        # Extract relevant spectrum, where
        #  vars_indexes only contains the relevant nodes
        #  jvar varies from 0 to len(vars_indexes)
        jvar = 0
        for ivar in range(spe.nvar):
            # the file pointer advances through all records to keep on track
            f.seek(4, 1)
            if ivar in vars_indexes:
                z[jvar, :] = unpack(endian+str(spe.npoin2)+\
                                         ftype, f.read(fsize*spe.npoin2))
                jvar += 1
            else:
                # the file pointer advances through all records to keep on track
                f.seek(fsize * spe.npoin2, 1)
            f.seek(4, 1)

        # linear interpolation
        ivar = 0
        for b_n, l_n in support2d:
            data[:] = 0.
            for inod in range(len(b_n)):
                jvar = np.where(vars_indexes == b_n[inod])[0][0]
                data += l_n[inod] * z[jvar, :]
            bnd.append_core_vars_slf([data])
            ivar += 1

        pbar.update(itime)
    pbar.finish()

    # Close bnd_file
    bnd.fole['hook'].close()

    print('   +> writing out the file with coordinate to impose')
    dat = [str(len(bor)) + ' 0']
    for i in np.sort(bor):
        dat.append(str(i) + ' ' + repr(geo.meshx[i-1]) + ' ' + \
                      repr(geo.meshy[i-1]) + ' 0.0')
    put_file_content(bnd_file + '.dat', dat)

    # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    # ~~~~ Jenkins' success message ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    print('\n\nMy work is done\n\n')

    sys.exit(0)
コード例 #5
0
def alter(options):
    """
    Modifications in the file
    """
    root_file = None
    if not options.freplace:
        if not options.parallel:
            if len(options.args) != 2:
                raise TelemacException(\
                        '\nThe code "alter" (without --replace) '
                        'requires 2 file names\n')
            slf_files = [options.args[0]]
            out_file = options.args[1]
        else:
            if len(options.args) != 3:
                raise TelemacException(\
                        '\nThe code "alter" (without --replace) '
                        'here requires 2 file names and '
                        '1 file root name for the partition\n')
            slf_files = [options.args[0]]
            root_file = options.args[1]
            out_file = options.args[2]
    else:
        slf_files = options.args
        out_file = "chop-tmp.slf"

    for slf_file in slf_files:
        slf_file = path.realpath(slf_file)
        if not path.exists(slf_file):
            raise TelemacException(\
                '\nCould not find the file named: {}'.format(slf_file))
        print('\n\nAltering ' + path.basename(slf_file) + ' within ' + \
                path.dirname(slf_file) + '\n'+'~'*72+'\n')
        vrs = options.xvars
        if options.xvars != None:
            vrs = clean_quotes(options.xvars.replace('_', ' '))
        times = (int(options.tfrom), int(options.tstep), int(options.tstop))
        slf = AlterSelafin(slf_file, times=times, vrs=vrs, root=root_file)
        if options.atitle != None:
            slf.alter_title(options.atitle)
        if options.areset:
            slf.alter_times(p_t=-slf.slf.tags['times'][0])
        if options.adate != None:
            slf.alter_datetime(date=options.adate.split('-'))
        if options.atime != None:
            slf.alter_datetime(time=options.atime.split(':'))
        if options.aswitch:
            slf.switch_vars()
        if options.eswitch:
            slf.alter_endian()
        if options.fswitch:
            slf.alter_float()
        if options.aname != None:
            slf.alter_vars(options.aname)
        slf.alter_times(m_t=float(options.atm), p_t=float(options.atp))
        slf.alter_mesh(m_x=float(options.axm), p_x=float(options.axp),
                       m_y=float(options.aym), p_y=float(options.ayp))
        if options.azname != None:
            slf.alter_values(options.azname,
                             m_z=float(options.azm), p_z=float(options.azp))
        if options.sph2ll != None:
            radius = 6371000.
            long0, lat0 = options.sph2ll.split(":")
            long0 = np.deg2rad(float(long0))
            lat0 = np.deg2rad(float(lat0))
            const = np.tan(lat0/2. + np.pi/4.)
            slf.slf.meshx = np.rad2deg(slf.slf.meshx/radius + long0)
            expo = np.exp(slf.slf.meshy/radius)
            slf.slf.meshy = np.rad2deg(2.*np.arctan(const*expo) - np.pi/2.)
        if options.ll2sph != None:
            radius = 6371000.
            long0, lat0 = options.ll2sph.split(":")
            long0 = np.deg2rad(float(long0))
            lat0 = np.deg2rad(float(lat0))
            slf.slf.meshx = radius * (np.deg2rad(slf.slf.meshx) - long0)
            slf.slf.meshy = radius * \
                      (np.log(np.tan(np.deg2rad(slf.slf.meshy)/2. + np.pi/4.)) \
                              - np.log(np.tan(lat0/2. + np.pi/4.)))
        if options.ll2utm != None:
            zone = int(options.ll2utm)
            slf.slf.meshx, slf.slf.meshy, zone = \
                      utm.from_lat_long(slf.slf.meshx, slf.slf.meshy, zone)
        if options.utm2ll != None:
            zone = int(options.utm2ll)
            slf.slf.meshx, slf.slf.meshy = \
                      utm.to_lat_long(slf.slf.meshx, slf.slf.meshy, zone)

        slf.put_content(out_file)

        if options.freplace:
            move_file(out_file, slf_file)