예제 #1
0
파일: manage.py 프로젝트: MiCurry/SharkEyes
def test(ids=None, navy=False, ncep=False):
    from pl_download.models import DataFile
    from pl_plot.plotter import NavyPlotter, NcepWW3Plotter
    from pl_plot.models import OverlayManager as om
    print ids


    if navy:
        print "NAVY HYCOM TEST"
        count = 0
        if ids:
            for id in ids:
                datafile = DataFile.objects.get(pk=id)
                if datafile.type != 'HYCOM':
                    continue # Skip over non HYCOM Files

                count += 1

            print "HYCOM TESTING ", count, " FOR FILE: "
            info(datafile)
            print "\tTESTING PLOTTER:"
            plotter = NavyPlotter(datafile.file.name)
            if plotter:
                print "\t PLOTTER LOADED SUCCESFULLY"
            else:
                print "\t ERROR: UNABLE TO LOAD FILE: ", datafile.file.name

            print "\t NUMBER OF MODEL TIMES: ", plotter.get_number_of_model_times()
            print "\t OCEAN TIME: ", plotter.get_time_at_oceantime_index()

            print "\t GENERATING PLOT.... "
            print ""

            if datafile.file.name.endswith("ssh.nc"):
                om.make_plot(settings.NAVY_HYCOM_SUR_CUR, 0, id)
            if datafile.file.name.endswith("temp_top.nc"):
                om.make_plot(settings.NAVY_HYCOM_SST, 0, id)
            if datafile.file.name.endswith("temp_bot.nc"):
                om.make_plot(settings.NAVY_HYCOM_BOT_TEMP, 0, id)
            if datafile.file.name.endswith("cur_top.nc"):
                om.make_plot(settings.NAVY_HYCOM_SUR_CUR, 0, id)
            if datafile.file.name.endswith("sal_top.nc"):
                om.make_plot(settings.NAVY_HYCOM_SUR_SAL, 0, id)

    if ncep:
        from pl_download.models import DataFileManager as dm

        print dm.ww3_download_openDAP()

    print "TESTING TASK CREATION"
예제 #2
0
파일: manage.py 프로젝트: wsf1990/SharkEyes
def test(ids=None, navy=False, ncep=False):
    from pl_download.models import DataFile
    from pl_plot.plotter import NavyPlotter, NcepWW3Plotter
    from pl_plot.models import OverlayManager as om
    print ids

    if navy:
        print "NAVY HYCOM TEST"
        count = 0
        if ids:
            for id in ids:
                datafile = DataFile.objects.get(pk=id)
                if datafile.type != 'HYCOM':
                    continue  # Skip over non HYCOM Files

                count += 1

            print "HYCOM TESTING ", count, " FOR FILE: "
            info(datafile)
            print "\tTESTING PLOTTER:"
            plotter = NavyPlotter(datafile.file.name)
            if plotter:
                print "\t PLOTTER LOADED SUCCESFULLY"
            else:
                print "\t ERROR: UNABLE TO LOAD FILE: ", datafile.file.name

            print "\t NUMBER OF MODEL TIMES: ", plotter.get_number_of_model_times(
            )
            print "\t OCEAN TIME: ", plotter.get_time_at_oceantime_index()

            print "\t GENERATING PLOT.... "
            print ""

            if datafile.file.name.endswith("ssh.nc"):
                om.make_plot(settings.NAVY_HYCOM_SUR_CUR, 0, id)
            if datafile.file.name.endswith("temp_top.nc"):
                om.make_plot(settings.NAVY_HYCOM_SST, 0, id)
            if datafile.file.name.endswith("temp_bot.nc"):
                om.make_plot(settings.NAVY_HYCOM_BOT_TEMP, 0, id)
            if datafile.file.name.endswith("cur_top.nc"):
                om.make_plot(settings.NAVY_HYCOM_SUR_CUR, 0, id)
            if datafile.file.name.endswith("sal_top.nc"):
                om.make_plot(settings.NAVY_HYCOM_SUR_SAL, 0, id)

    if ncep:
        from pl_download.models import DataFileManager as dm

        print dm.ww3_download_openDAP()

    print "TESTING TASK CREATION"
예제 #3
0
파일: manage.py 프로젝트: wsf1990/SharkEyes
def plot(ids=[],
         num_plots=DEF_NUM_PLOTS,
         tile_flag=DEF_TILE_FLAG,
         full_roms=DEF_FULL_ROMS_FLAG,
         roms=False,
         wave=False,
         wind=False,
         hycom=False,
         ncep=False,
         tcline=False,
         navy=False):
    '''  Just generates plots. You need to pass in the df id to get a plot! Pass it in manually
    or by using one of the functions below which grabs them using the database or via downloading!
    '''
    print "IDS", ids

    if not ids:
        print "PLOT: NO IDS SUBMITTED TO BE PLOTTED - exiting"
        return

    if len(ids) == 0:
        print "PLOT: Empty List of IDS exiting"
        return

    from pl_plot.models import OverlayManager as om
    from pl_chop.tasks import tile_overlay

    if roms:  # OSU ROMS
        roms = []

        print "PLOT: Plotting Roms with file IDS: ", ids
        for id in ids:
            for i in range(num_plots):
                print "PLOT: OSU ROMS SST - timeslice: ", i
                roms.append(om.make_plot(settings.OSU_ROMS_SST, i, id))
                print "PLOT: OSU ROMS SSC - timeslice: ", i
                roms.append(om.make_plot(settings.OSU_ROMS_SUR_CUR, i, id))

                if full_roms:
                    print "PLOT: Plotting full roms"
                    print "PLOT: OSU ROMS SSC - timeslice: ", i
                    roms.append(om.make_plot(settings.OSU_ROMS_SUR_SAL, i, id))
                    print "PLOT: OSU ROMS BOT Sal- timeslice: ", i
                    roms.append(om.make_plot(settings.OSU_ROMS_BOT_SAL, i, id))
                    print "PLOT: OSU ROMS BOT Temp- timeslice: ", i
                    roms.append(om.make_plot(settings.OSU_ROMS_BOT_TEMP, i,
                                             id))
                    print "PLOT: OSU ROMS SSH - timeslice: ", i
                    roms.append(om.make_plot(settings.OSU_ROMS_SSH, i, id))

        if tile_flag:
            print "PLOT: Tiling ROMS"
            tile(roms)

        return

    if wave:  # OSU WAVE WATCH III - NO LONGER AVIABLE
        waves = []

        print ids
        print "PLOT: Plotting OSU WW3 with file IDS: ", ids

        if not ids:
            print "Empty List of IDS for OSU WW3"
            return

        for id in ids:
            for i in range(num_plots):
                waves.append(
                    om.make_wave_watch_plot(settings.OSU_WW3_HI, i, id))
                waves.append(
                    om.make_wave_watch_plot(settings.OSU_WW3_DIR, i, id))

        if tile_flag:
            print "PLOT: Tiling waves"
            tile(waves)

        return

    if wind:  # NORTH AMERICAN MESOSCALE - SURFACE WINDS
        winds = []

        print "PLOT: Plotting NAM Winds with file IDS: ", ids
        for id in ids:
            for i in range(num_plots):
                winds.append(om.make_plot(settings.NAMS_WIND, i, id))

        if tile_flag:
            print "PLOT: Tiling NAM Winds"
            tile(winds)

        return

    if hycom:  # NOAA HYCOM - Not currently implemented on the seacast.org
        hycoms = []

        print "PLOT: Plotting HYCOM with file IDS: ", ids
        for id in ids:
            hycoms.append(om.make_plot(settings.HYCOM_SST, 0, id))
            hycoms.append(om.make_plot(settings.HYCOM_SUR_CUR, 0, id))

        if tile_flag:
            print "PLOT: Tiling HYCOM"
            tile(hycoms)

        return

    if ncep:  # NCEP WAVE WATCH III
        nceps = []

        print ids
        print "PLOT: Plotting NCEP WW3 with file IDS: ", ids
        for id in ids:
            for i in range(num_plots):
                nceps.append(
                    om.make_wave_watch_plot(settings.NCEP_WW3_DIR, i, id))
                nceps.append(
                    om.make_wave_watch_plot(settings.NCEP_WW3_HI, i, id))

        if tile_flag:
            print "PLOT: Tiling NCEP"
            tile(nceps)

        return

    if tcline:  # OSU ROMS THERMOCLINE
        tcline_ids = []

        print ids
        print "PLOT: Plotting TCLINE with file IDS: ", ids
        for id in ids:
            for i in range(num_plots):
                tcline_ids.append(om.make_plot(settings.OSU_ROMS_TCLINE, i,
                                               id))

        if tile_flag:
            print "PLOT: Tiling tcline"
            tile(tcline_ids)

        return

    if navy:  # NAVY HYCOM
        navy_ids = []

        print ids
        print "PLOT: Plotting NCEP WW3 with file IDS: ", ids
        for id in ids:
            for i in range(num_plots):
                navy_ids.append(om.make_plot(settings.NAVY_HYCOM_SST, i, id))
                navy_ids.append(
                    om.make_plot(settings.NAVY_HYCOM_SUR_CUR, i, id))

        if tile_flag:
            print "PLOT: Tiling NCEP"
            tile(navy_ids)

        return
예제 #4
0
파일: manage.py 프로젝트: seacast/SharkEyes
            #need to offset 16 to match with sst plot
            #NOTE it increments in 1 hour changes
            tiles += OverlayManager.make_wave_watch_plot(4, 16, wave[0])
            tiles += OverlayManager.make_wave_watch_plot(6, 16, wave[0])
            for t in tiles:
                tile_wave_watch_overlay(t)
            finish = time.time()
            totalTime = (finish - begin)/ 60
            print "Time taken for Waves = " + str(round(totalTime, 2)) + " minutes"
        if sst:
            sst = DataFileManager.fetch_new_files()
            tiles = []
            #first entry is day at 4am
            #NOTE it increments in 4 hour changes
            begin = time.time()
            tiles += OverlayManager.make_plot(1, 0, sst[0])
            tiles += OverlayManager.make_plot(3, 0, sst[0])
            for t in tiles:
                tile_overlay(t)
            finish = time.time()
            totalTime = (finish - begin)/ 60
            print "Time taken for SST = " + str(round(totalTime, 2)) + " minutes"

        if wind:
            winds = DataFileManager.get_wind_file()
            winds = DataFile.objects.filter(type='WIND').latest('model_date')
            tiles = []
            begin = time.time()
            tiles += OverlayManager.make_plot(5, 0, winds)
            for t in tiles:
                tile_overlay(t)
예제 #5
0
파일: manage.py 프로젝트: MiCurry/SharkEyes
def plot(ids=[],
         num_plots=DEF_NUM_PLOTS, tile_flag=DEF_TILE_FLAG, full_roms=DEF_FULL_ROMS_FLAG,
         roms=False, wave=False, wind=False, hycom=False, ncep=False, tcline=False, navy=False):
    '''  Just generates plots. You need to pass in the df id to get a plot! Pass it in manually
    or by using one of the functions below which grabs them using the database or via downloading!
    '''
    print "IDS", ids

    if not ids:
        print "PLOT: NO IDS SUBMITTED TO BE PLOTTED - exiting"
        return

    if len(ids) == 0:
        print "PLOT: Empty List of IDS exiting"
        return

    from pl_plot.models import OverlayManager as om
    from pl_chop.tasks import tile_overlay

    if roms: # OSU ROMS
        roms = []

        print "PLOT: Plotting Roms with file IDS: ", ids
        for id in ids:
            for i in range(num_plots):
                print "PLOT: OSU ROMS SST - timeslice: ", i
                roms.append(om.make_plot(settings.OSU_ROMS_SST, i, id))
                print "PLOT: OSU ROMS SSC - timeslice: ", i
                roms.append(om.make_plot(settings.OSU_ROMS_SUR_CUR, i, id))

                if full_roms:
                    print "PLOT: Plotting full roms"
                    print "PLOT: OSU ROMS SSC - timeslice: ", i
                    roms.append(om.make_plot(settings.OSU_ROMS_SUR_SAL, i, id))
                    print "PLOT: OSU ROMS BOT Sal- timeslice: ", i
                    roms.append(om.make_plot(settings.OSU_ROMS_BOT_SAL, i, id))
                    print "PLOT: OSU ROMS BOT Temp- timeslice: ", i
                    roms.append(om.make_plot(settings.OSU_ROMS_BOT_TEMP, i, id))
                    print "PLOT: OSU ROMS SSH - timeslice: ", i
                    roms.append(om.make_plot(settings.OSU_ROMS_SSH, i, id))

        if tile_flag:
            print "PLOT: Tiling ROMS"
            tile(roms)

        return

    if wave: # OSU WAVE WATCH III - NO LONGER AVIABLE
        waves = []

        print ids
        print "PLOT: Plotting OSU WW3 with file IDS: ", ids

        if not ids:
            print "Empty List of IDS for OSU WW3"
            return

        for id in ids:
            for i in range(num_plots):
                waves.append(om.make_wave_watch_plot(settings.OSU_WW3_HI, i, id))
                waves.append(om.make_wave_watch_plot(settings.OSU_WW3_DIR, i, id))

        if tile_flag:
            print "PLOT: Tiling waves"
            tile(waves)

        return

    if wind: # NORTH AMERICAN MESOSCALE - SURFACE WINDS
        winds = []

        print "PLOT: Plotting NAM Winds with file IDS: ", ids
        for id in ids:
            for i in range(num_plots):
                winds.append(om.make_plot(settings.NAMS_WIND, i, id))

        if tile_flag:
            print "PLOT: Tiling NAM Winds"
            tile(winds)

        return

    if hycom: # NOAA HYCOM - Not currently implemented on the seacast.org
        hycoms = []

        print "PLOT: Plotting HYCOM with file IDS: ", ids
        for id in ids:
            hycoms.append(om.make_plot(settings.HYCOM_SST, 0, id))
            hycoms.append(om.make_plot(settings.HYCOM_SUR_CUR, 0, id))

        if tile_flag:
            print "PLOT: Tiling HYCOM"
            tile(hycoms)

        return

    if ncep: # NCEP WAVE WATCH III
        nceps = []

        print ids
        print "PLOT: Plotting NCEP WW3 with file IDS: ", ids
        for id in ids:
            for i in range(num_plots):
                nceps.append(om.make_wave_watch_plot(settings.NCEP_WW3_DIR, i, id))
                nceps.append(om.make_wave_watch_plot(settings.NCEP_WW3_HI, i, id))

        if tile_flag:
            print "PLOT: Tiling NCEP"
            tile(nceps)

        return

    if tcline: # OSU ROMS THERMOCLINE
        tcline_ids = []

        print ids
        print "PLOT: Plotting TCLINE with file IDS: ", ids
        for id in ids:
            for i in range(num_plots):
                tcline_ids.append(om.make_plot(settings.OSU_ROMS_TCLINE, i, id))

        if tile_flag:
            print "PLOT: Tiling tcline"
            tile(tcline_ids)

        return

    if navy: # NAVY HYCOM
        navy_ids = []

        print ids
        print "PLOT: Plotting NCEP WW3 with file IDS: ", ids
        for id in ids:
            for i in range(num_plots):
                navy_ids.append(om.make_plot(settings.NAVY_HYCOM_SST, i, id))
                navy_ids.append(om.make_plot(settings.NAVY_HYCOM_SUR_CUR, i, id))


        if tile_flag:
            print "PLOT: Tiling NCEP"
            tile(navy_ids)

        return
예제 #6
0
파일: manage.py 프로젝트: MiCurry/manage.py
def test(ids=None, navy=False, ncep=False):
    from pl_download.models import DataFile
    from pl_plot.plotter import NavyPlotter, NcepWW3Plotter
    from pl_plot.models import OverlayManager as om
    print ids


    if navy:
        print "NAVY HYCOM TEST"
        count = 0
        if ids:
            for id in ids:
                datafile = DataFile.objects.get(pk=id)
                if datafile.type != 'HYCOM':
                    continue # Skip over non HYCOM Files

                count += 1

            print "HYCOM TESTING ", count, " FOR FILE: "
            info(datafile)
            print "\tTESTING PLOTTER:"
            plotter = NavyPlotter(datafile.file.name)
            if plotter:
                print "\t PLOTTER LOADED SUCCESFULLY"
            else:
                print "\t ERROR: UNABLE TO LOAD FILE: ", datafile.file.name

            print "\t NUMBER OF MODEL TIMES: ", plotter.get_number_of_model_times()
            print "\t OCEAN TIME: ", plotter.get_time_at_oceantime_index()

            print "\t GENERATING PLOT.... "
            print ""

            if datafile.file.name.endswith("ssh.nc"):
                om.make_plot(settings.NAVY_HYCOM_SUR_CUR, 0, id)
            if datafile.file.name.endswith("temp_top.nc"):
                om.make_plot(settings.NAVY_HYCOM_SST, 0, id)
            if datafile.file.name.endswith("temp_bot.nc"):
                om.make_plot(settings.NAVY_HYCOM_BOT_TEMP, 0, id)
            if datafile.file.name.endswith("cur_top.nc"):
                om.make_plot(settings.NAVY_HYCOM_SUR_CUR, 0, id)
            if datafile.file.name.endswith("sal_top.nc"):
                om.make_plot(settings.NAVY_HYCOM_SUR_SAL, 0, id)

    if ncep:
        print "NCEP TEST"
        count = 0
        for id in ids:
            datafile = DataFile.objects.get(pk=id)
            if datafile.type != 'NCEP':
                continue # Skip over non HYCOM Files

            count += 1

            print "NCEP WW3 TESTING ", count, " FOR FILE: "
            info(datafile)

            print "   TESTING PLOTTER:"
            plotter = NcepWW3Plotter(datafile.file.name)
            if plotter:
                print "   PLOTTER LOADED SUCCESFULLY"
            else:
                print "   ERROR: UNABLE TO LOAD FILE: ", datafile.file.name

            print "\tNUMBER OF MODEL TIMES: ", plotter.get_number_of_model_times()
            print "\tOCEAN TIMES & TASKS: "
            list = om.get_tasks_for_base_plots_for_next_few_days()
            for i in range(plotter.get_number_of_model_times()):
                print "\t", list[i], "-- time:", plotter.get_oceantime(i)

            print "   GENERATING PLOTS.... "
            cnt = 0
            for i in range(plotter.get_number_of_model_times()):
                print " PLOT: ", cnt, " of", plotter.get_number_of_model_times()
                om.make_wave_watch_plot(settings.NCEP_WW3_DIR, i, id)
                cnt += 1
                print " PLOT: ", cnt, " of", plotter.get_number_of_model_times()
                om.make_wave_watch_plot(settings.NCEP_WW3_HI, i, id)
                cnt += 1

    print "TESTING TASK CREATION"
예제 #7
0
파일: manage.py 프로젝트: MiCurry/manage.py
def plot_by_id(ids=None):
    if ids == None:
        print "PLOT_BY_ID: NO IDS SUPPLIED ... Quitting"
        return 0

    from pl_download.models import DataFile as df
    from pl_plot.models import OverlayManager as om

    for id in ids:
        file = df.objects.get(pk=id)
        print_file_info(file)

        if file.type == 'NCDF':
            om.make_plot()

        elif file.type == 'WAVE':
            om.make_plot()

        elif file.type == 'WIND':
            om.make_plot()

        elif file.type == 'T-CLINE':
            om.make_plot()

        elif file.type == 'NCEP_WW3':
            om.make_plot()

        elif file.type == 'HYCOM':
            om.make_plot()

        elif file.type == 'RTOFS':
            om.make_plot()