start = timevar.units.date2num(jd_start)
            istart = timevar.nearest_neighbour_index(start)
            stop = timevar.units.date2num(jd_stop)
            istop = timevar.nearest_neighbour_index(stop)

            # Only proceed if we have data in the range requested.
            if istart != istop:
                nsta = len(stations)
                if len(r) == 4:
                    # HYCOM and ROMS
                    # Dimensions are time, elevation, lat, lon
                    d = u[0, 0:1, :, :].data
                    # Find the closest non-land point from a structured grid model.
                    if len(lon.shape) == 1:
                        lon, lat = np.meshgrid(lon, lat)
                    j, i, dd = find_ij(lon, lat, d, obs_lon, obs_lat)

                    for n in range(nsta):
                        # Only use if model cell is within max_dist of station
                        if dd[n] <= max_dist:
                            u_arr = u[istart:istop, 0:1, j[n], i[n]].data
                            v_arr = v[istart:istop, 0:1, j[n], i[n]].data
                            arr = np.sqrt(u_arr ** 2 + v_arr ** 2)
                            if u_arr.std() >= min_var:
                                c = mod_df(arr, timevar, istart, istop, mod_name, ts)
                                name = obs_df[n].name
                                model_df[n] = pd.concat([model_df[n], c], axis=1)
                                model_df[n].name = name
                            else:
                                print "min_var error"
                        else:
Example #2
0
        jd = timevar.units.num2date(timevar.points)
        start = timevar.units.date2num(jd_start)
        istart = timevar.nearest_neighbour_index(start)
        stop = timevar.units.date2num(jd_stop)
        istop = timevar.nearest_neighbour_index(stop)

        # Only proceed if we have data in the range requested.
        if istart != istop:
            nsta = len(station_list)
            if len(r) == 3:
                print('[Structured grid model]:', url)
                d = a[0, :, :].data
                # Find the closest non-land point from a structured grid model.
                if len(lon.shape) == 1:
                    lon, lat = np.meshgrid(lon, lat)
                j, i, dd = find_ij(lon, lat, d, obs_lon, obs_lat)
                for n in range(nsta):
                    # Only use if model cell is within 0.04 degree of requested
                    # location.
                    if dd[n] <= max_dist:
                        arr = a[istart:istop, j[n], i[n]].data
                        if arr.std() >= min_var:
                            c = mod_df(arr, timevar, istart, istop, mod_name,
                                       ts)
                            name = station_list[n]['long_name']
                            model_df[n] = pd.concat([model_df[n], c], axis=1)
                            model_df[n].name = name

            elif len(r) == 2:
                print('[Unstructured grid model]:', url)
                # Find the closest point from an unstructured grid model.
        # Only proceed if we have data in the range requested.
        if istart != istop:
            nsta = len(stations)

            if len(r) == 3:
                print('[Structured grid model]:', url)
                d = u[0, :, :].data

                if len(lon.shape) == 1:
                    new_lon, new_lat = np.meshgrid(lon, lat)
                else:
                    new_lon, new_lat = lon, lat

                # Find the closest non-land point from a structured grid model.
                j, i, dd = find_ij(new_lon, new_lat, d, obs_lon, obs_lat)

                # Keep the lat lon of the grid point
                model_lat = lat[j].tolist()
                model_lon = lon[i].tolist()

                for n in range(nsta):
                    # Only use if model cell is within max_dist of station
                    if dd[n] <= max_dist:
                        u_arr = u[istart:istop, j[n], i[n]].data
                        v_arr = v[istart:istop, j[n], i[n]].data
                        # Model data is in m/s so convert to cm/s
                        arr = np.sqrt((u_arr)**2 + (v_arr)**2)
                        if u_arr.std() >= min_var:
                            c = mod_df(arr, timevar, istart, istop, mod_name,
                                       ts)
Example #4
0
    start = timevar.units.date2num(jd_start)
    istart = timevar.nearest_neighbour_index(start)
    stop = timevar.units.date2num(jd_stop)
    istop = timevar.nearest_neighbour_index(stop)

    # Only proceed if we have data in the range requested.
    if istart != istop:
        # Wave Watch III uses a 4D grid (time, z, lat, lon)
        d = cube[0, 0, :, :].data
        if len(lon.shape) == 1:
            new_lon, new_lat = np.meshgrid(lon, lat)
        else:
            new_lon, new_lat = lon, lat

        # Find the closest non-land point from a structured grid model.
        j, i, dd = find_ij(new_lon, new_lat, d, station_lon, station_lat)

        # Keep the lat lon of the grid point
        model_lat = lat[j].tolist()
        model_lon = lon[i].tolist()

        # Only use if model cell is within max_dist of station
        if dd <= max_dist:
            arr = cube[istart:istop, 0, j, i].data
            if arr.std() >= min_var:
                c = mod_df(arr, timevar, istart, istop, mod_name, ts)
                model_df = pd.concat([model_df, c], axis=1)
                model_df.name = get_station_longName(str(station_id))
            else:
                print 'Min variance error'
        else:
        # Only proceed if we have data in the range requested.
        if istart != istop:
            nsta = len(stations)
            
            if len(r) == 3:
                print('[Structured grid model]:', url)
                d = u[0, :, :].data
                    
                if len(lon.shape) == 1:
                    new_lon, new_lat = np.meshgrid(lon, lat)
                else:
                    new_lon, new_lat = lon, lat
                
                # Find the closest non-land point from a structured grid model.
                j, i, dd = find_ij(new_lon, new_lat, d, obs_lon, obs_lat)

                # Keep the lat lon of the grid point
                model_lat = lat[j].tolist()
                model_lon = lon[i].tolist()
 
                for n in range(nsta):
                    # Only use if model cell is within max_dist of station
                    if dd[n] <= max_dist:
                        u_arr = u[istart:istop, j[n], i[n]].data
                        v_arr = v[istart:istop, j[n], i[n]].data
                        # Model data is in m/s so convert to cm/s
                        arr = np.sqrt((u_arr)**2 + (v_arr)**2)
                        if u_arr.std() >= min_var:
                            c = mod_df(arr, timevar, istart, istop,
                                       mod_name, ts)
Example #6
0
    start = timevar.units.date2num(jd_start)
    istart = timevar.nearest_neighbour_index(start)
    stop = timevar.units.date2num(jd_stop)
    istop = timevar.nearest_neighbour_index(stop)

    # Only proceed if we have data in the range requested.
    if istart != istop:
        # Wave Watch III uses a 4D grid (time, z, lat, lon)
        d = cube[0, 0, :, :].data
        if len(lon.shape) == 1:
            new_lon, new_lat = np.meshgrid(lon, lat)
        else:
            new_lon, new_lat = lon, lat

        # Find the closest non-land point from a structured grid model.
        j, i, dd = find_ij(new_lon, new_lat, d, station_lon, station_lat)

        # Keep the lat lon of the grid point
        model_lat = lat[j].tolist()
        model_lon = lon[i].tolist()

        # Only use if model cell is within max_dist of station
        if dd <= max_dist:
            arr = cube[istart:istop, 0, j, i].data
            if arr.std() >= min_var:
                c = mod_df(arr, timevar, istart, istop,
                           mod_name, ts)
                model_df = pd.concat([model_df, c], axis=1)
                model_df.name = get_station_longName(str(station_id))
            else:
                print 'Min variance error'