Beispiel #1
0
def run():

    # Location of TXLA model output
    loc = 'http://barataria.tamu.edu:8080/thredds/dodsC/NcML/txla_nesting6.nc'

    # Make sure necessary directories exist
    if not os.path.exists('tracks'):
        os.makedirs('tracks')
    if not os.path.exists('figures'):
        os.makedirs('figures')

    grid = tracpy.inout.readgrid(loc)

    # startdates = np.array([datetime(2006, 7, 1, 0, 1)])
    date = np.array([datetime(2006, 2, 1, 0, 1)])#, datetime(2006, 7, 1, 0, 1)])
    # pdb.set_trace()

    # drifter initial separation distance in meters
    dxs = np.array([20000,15000,10000,7500,5000,2500,1000,750,500,250])
    # Max volume a drifter can represent
    Vs = np.array([100,75,50,25])
    # Drifter array test areas
    Seeds = ['A','B','C']


    # loop through run parameters
    for dx in dxs:
        for Vmax in Vs:
            for Seed in Seeds:

                # Read in simulation initialization
                nstep, ndays, ff, tseas, ah, av, lon0, lat0, z0, zpar, do3d, doturb, \
                        grid, dostream, N, T0, U, V, name = init.disp(Seed, dx, Vmax, 
                                                            date, loc, grid=grid)

                # If the particle trajectories have not been run, run them
                if not os.path.exists('tracks/' + name + '.nc'):

                    # Run tracpy
                    lonp, latp, zp, t, grid, T0, U, V \
                        = tracpy.run.run(loc, nstep, ndays, ff, date, tseas, ah, av, \
                                            lon0, lat0, z0, zpar, do3d, doturb, name, \
                                            grid=grid, dostream=dostream, N=N, T0=T0, U=U, V=V)

                # If basic figures don't exist, make them
                if not os.path.exists('figures/' + name + '*.png'):

                    # Read in and plot tracks
                    d = netCDF.Dataset('tracks/' + name + '.nc')
                    lonp = d.variables['lonp'][:]
                    latp = d.variables['latp'][:]
                    tracpy.plotting.tracks(lonp, latp, name, grid=grid)
                    # tracpy.plotting.hist(lonp, latp, name, grid=grid, which='hexbin')
                    d.close()
                    # Do transport plot
                    tracpy.plotting.transport(name='', fmod=name, extraname=name,
                        Title='Transport on Shelf', dmax=1.0)
                    plt.close("all")
def run():

    # Location of TXLA model output
    loc = 'http://barataria.tamu.edu:8080/thredds/dodsC/NcML/txla_nesting6.nc'

    # Make sure necessary directories exist
    if not os.path.exists('tracks'):
        os.makedirs('tracks')
    if not os.path.exists('figures'):
        os.makedirs('figures')

    grid = tracpy.inout.readgrid(loc)

    # Weekly Oct, Nov, Dec; biweekly Jan, Feb, Mar; monthly Apr, May, Jun, Jul
    # startdates = np.array([datetime(2010, 2, 1, 0, 1), datetime(2010, 2, 15, 0, 1),
    #                         datetime(2010, 3, 1, 0, 1), datetime(2010, 3, 15, 0, 1),
    #                         datetime(2010, 4, 1, 0, 1), datetime(2010, 5, 1, 0, 1),
    #                         datetime(2010, 6, 1, 0, 1), datetime(2010, 7, 1, 0, 1)])
    startdates = np.array([datetime(2009, 10, 1, 0, 1), datetime(2009, 10, 8, 0, 1),
                            datetime(2009, 10, 15, 0, 1), datetime(2009, 10, 22, 0, 1),
                            datetime(2009, 11, 1, 0, 1), datetime(2009, 11, 8, 0, 1),
                            datetime(2009, 11, 15, 0, 1), datetime(2009, 11, 22, 0, 1),
                            datetime(2009, 12, 1, 0, 1), datetime(2009, 12, 8, 0, 1),
                            datetime(2009, 12, 15, 0, 1), datetime(2009, 12, 22, 0, 1),
                            datetime(2010, 1, 1, 0, 1), datetime(2010, 1, 15, 0, 1),
                            datetime(2010, 2, 1, 0, 1), datetime(2010, 2, 15, 0, 1),
                            datetime(2010, 3, 1, 0, 1), datetime(2010, 3, 15, 0, 1),
                            datetime(2010, 4, 1, 0, 1), datetime(2010, 5, 1, 0, 1),
                            datetime(2010, 6, 1, 0, 1), datetime(2010, 7, 1, 0, 1)])

    # loop through state dates
    for startdate in startdates:

        date = startdate

        # Read in simulation initialization
        nstep, ndays, ff, tseas, ah, av, lon0, lat0, z0, zpar, do3d, doturb, \
                grid, dostream = init.disp(date, loc, grid=grid)
        # nstep, ndays, ff, tseas, ah, av, lon0, lat0, z0, zpar, do3d, doturb, \
        #         grid, dostream, N, T0, U, V = init.disp(date, loc, grid=grid)

        # for dt test:
        mod = 'doturb' + str(doturb) + '_ah' + str(int(ah)) + '_nsteps50/'
        # original test:
        # mod = 'doturb' + str(doturb) + '_ah' + str(int(ah)) + '/'

        if not os.path.exists('tracks/' + mod):
            os.makedirs('tracks/' + mod)
        if not os.path.exists('figures/' + mod):
            os.makedirs('figures/' + mod)

        name =  mod + date.isoformat()[0:13] 


        # If the particle trajectories have not been run, run them
        if not os.path.exists('tracks/' + name + '.nc'):

            # Run tracpy
            lonp, latp, zp, t, grid \
                = tracpy.run.run(loc, nstep, ndays, ff, date, tseas, ah, av, \
                                    lon0, lat0, z0, zpar, do3d, doturb, name, \
                                    grid=grid, dostream=dostream)
            # lonp, latp, zp, t, grid, T0, U, V \
            #     = tracpy.run.run(loc, nstep, ndays, ff, date, tseas, ah, av, \
            #                         lon0, lat0, z0, zpar, do3d, doturb, name, \
            #                         grid=grid, dostream=dostream, T0=T0, U=U, V=V)

        # # If basic figures don't exist, make them
        # if not os.path.exists('figures/' + name + '*.png'):

            # Read in and plot tracks
            d = netCDF.Dataset('tracks/' + name + '.nc')
            lonp = d.variables['lonp'][:]
            latp = d.variables['latp'][:]
            tracpy.plotting.tracks(lonp, latp, name, grid=grid)
            # tracpy.plotting.hist(lonp, latp, name, grid=grid, which='hexbin')
            d.close()