|
32 | 32 | from salishsea_tools import nc_tools, tidetools as tt, viz_tools, geo_tools
|
33 | 33 | from scipy import interpolate as interp
|
34 | 34 |
|
35 |
| -from nowcast import analyze, residuals |
| 35 | +from nowcast import residuals |
36 | 36 |
|
37 | 37 | # Font format
|
38 | 38 | title_font = {
|
@@ -242,12 +242,9 @@ def unstag_rot(ugrid, vgrid):
|
242 | 242 | :arg vgrid: v velocity component values with axes (..., y, x)
|
243 | 243 | :type vgrid: :py:class:`numpy.ndarray`
|
244 | 244 |
|
245 |
| - :arg station: Name of the station ('East' or 'Central') |
246 |
| - :type station: string |
247 |
| -
|
248 | 245 | :returns u_E, v_N, depths: u_E and v_N velocties is the North and East
|
249 |
| - directions at the cell center, |
250 |
| - and the depth of the station |
| 246 | + directions at the cell center, |
| 247 | + and the depth of the station |
251 | 248 | """
|
252 | 249 |
|
253 | 250 | # We need to access the u velocity that is between i and i-1
|
@@ -532,253 +529,30 @@ def load_vel(day, grid, source, station, deprange):
|
532 | 529 | return u, v, dep
|
533 | 530 |
|
534 | 531 |
|
535 |
| -## TODO: Move/rename to figures.comparison as adcp_something module |
536 |
| -def plotADCP(grid_m, grid_o, day, station, profile): |
537 |
| - """This function will plots the velocities on a colour map with depth of the |
538 |
| - model and observational values. |
539 |
| - data over a whole day at a particular station. |
540 |
| -
|
541 |
| - :arg grid_m: The model grid |
542 |
| - :type grid_m: neCDF4 dataset. |
543 |
| -
|
544 |
| - :arg grid_o: The observational grid |
545 |
| - :type grid_o: dictionary |
546 |
| -
|
547 |
| - :arg day: day of interest |
548 |
| - :type day: datetime object |
549 |
| -
|
550 |
| - :arg station: Station of interest. Either 'Central' or 'East' or 'ddl'. |
551 |
| - :type station: string |
552 |
| -
|
553 |
| - :arg profile: the range of depths that will be looked at in meters. |
554 |
| - (ex. [min, max]) |
555 |
| - :type profile: list |
556 |
| -
|
557 |
| - :return: fig |
558 |
| - """ |
559 |
| - # Get grids into unstaggered and masked velocities at the chose depths |
560 |
| - u_E, v_N, dep_t = load_vel(day, grid_m, "model", station, profile) |
561 |
| - u, v, dep = load_vel(day, grid_o, "observation", station, profile) |
562 |
| - |
563 |
| - # Begin figure |
564 |
| - fig, ([axmu, axou], [axmv, axov]) = plt.subplots( |
565 |
| - 2, 2, figsize=(20, 10), sharex=True |
566 |
| - ) |
567 |
| - fig.patch.set_facecolor("#2B3E50") |
568 |
| - |
569 |
| - # Find the absolute maximum value between the model and observational |
570 |
| - # velocities to set the colorbar |
571 |
| - max_v = np.nanmax(abs(v)) |
572 |
| - max_u = np.nanmax(abs(u)) |
573 |
| - max_vm = np.nanmax(abs(v_N)) |
574 |
| - max_um = np.nanmax(abs(u_E)) |
575 |
| - max_speed = np.amax([max_v, max_u, max_vm, max_um]) |
576 |
| - vmax = np.ceil(max_speed * 10) / 10.0 |
577 |
| - vmin = -vmax |
578 |
| - step = 0.05 |
579 |
| - cs = np.arange(vmin, vmax + step, step) |
580 |
| - |
581 |
| - cmap = plt.get_cmap("bwr") |
582 |
| - |
583 |
| - # Setting the date for title |
584 |
| - date = day.strftime("%d%b%y") |
585 |
| - |
586 |
| - # Plotting the comparison between the model and the obs velocities |
587 |
| - increment = [0.25, 0.5, 0.25, 0.5] |
588 |
| - velocities = [u_E.transpose(), u, v_N.transpose(), v] |
589 |
| - axes = [axmu, axou, axmv, axov] |
590 |
| - depths = [dep_t, dep, dep_t, dep] |
591 |
| - names = ["Model", "Observations", "Model", "Observations"] |
592 |
| - direction = ["East/West", "East/West", "North/South", "North/South"] |
593 |
| - |
594 |
| - for ax, vel, timestep, depth, name, direc in zip( |
595 |
| - axes, velocities, increment, depths, names, direction |
596 |
| - ): |
597 |
| - ax.invert_yaxis() |
598 |
| - mesh = ax.contourf( |
599 |
| - # The range below adjusts for the observations starting at 00:15 |
600 |
| - # and being in 30 minutes increments. |
601 |
| - np.arange(timestep - 0.25, 24 + timestep - 0.25, timestep), |
602 |
| - depth[:], |
603 |
| - vel, |
604 |
| - cs, |
605 |
| - cmap=cmap, |
606 |
| - ) |
607 |
| - ax.set_ylim([profile[1], profile[0]]) |
608 |
| - ax.set_xlim([0.25, 23]) |
609 |
| - ax.set_ylabel("Depth [m]", **axis_font) |
610 |
| - |
611 |
| - axis_colors(ax, "gray") |
612 |
| - ax.set_title( |
613 |
| - f"{direc} {name} Velocities at VENUS {station} - {date}", **title_font |
614 |
| - ) |
615 |
| - |
616 |
| - cbar_ax = fig.add_axes([0.95, 0.2, 0.03, 0.6]) |
617 |
| - cbar = fig.colorbar(mesh, cax=cbar_ax) |
618 |
| - plt.setp(plt.getp(cbar.ax.axes, "yticklabels"), color="w") |
619 |
| - cbar.set_label("[m/s]", **axis_font) |
620 |
| - axmv.set_xlabel("Hour [UTC]", **axis_font) |
621 |
| - axov.set_xlabel("Hour [UTC]", **axis_font) |
622 |
| - |
623 |
| - return fig |
624 |
| - |
625 |
| - |
626 |
| -## TODO: Move/rename to figures.comparison as adcp_time_avg module |
627 |
| -def plottimeavADCP(grid_m, grid_o, day, station): |
628 |
| - """This function plots a comparison of the time averaged velocities of the |
629 |
| - model and the observations. |
630 |
| -
|
631 |
| - :arg grid_m: The model grid |
632 |
| - :type grid_m: neCDF4 dataset. |
633 |
| -
|
634 |
| - :arg grid_o: The observational grid |
635 |
| - :type grid_o: dictionary |
636 |
| -
|
637 |
| - :arg day: day of interest |
638 |
| - :type day: datetime object |
639 |
| -
|
640 |
| - :arg station: Station of interest. Either 'Central' or 'East' or 'ddl' |
641 |
| - :type station: string |
642 |
| -
|
643 |
| - :return: fig |
644 |
| - """ |
645 |
| - if station == "Central": |
646 |
| - profile = [0, 290] |
647 |
| - elif station == "East": |
648 |
| - profile = [0, 150] |
649 |
| - else: |
650 |
| - profile = [0, 150] |
651 |
| - |
652 |
| - # Get grids into unstaggered and masked velocities at the chose depths |
653 |
| - u_E, v_N, dep_t = load_vel(day, grid_m, "model", station, profile) |
654 |
| - u, v, dep = load_vel(day, grid_o, "observation", station, profile) |
655 |
| - |
656 |
| - # Begin figure |
657 |
| - fig, ([ax1, ax2]) = plt.subplots(1, 2, figsize=(8, 10), sharex=True) |
658 |
| - fig.patch.set_facecolor("#2B3E50") |
659 |
| - |
660 |
| - # Setting the date for title |
661 |
| - date = day.strftime("%d%b%y") |
662 |
| - |
663 |
| - velocities = [u_E[:, :-1], v_N[:, :-1]] |
664 |
| - vellast = [u_E[:, -2:], v_N[:, -2:]] |
665 |
| - veloobs = [u, v] |
666 |
| - axes = [ax1, ax2] |
667 |
| - direction = ["E/W", "N/S"] |
668 |
| - |
669 |
| - for ax, vel, velo, lastvel, direc in zip( |
670 |
| - axes, velocities, veloobs, vellast, direction |
671 |
| - ): |
672 |
| - ax.plot(np.nanmean(vel, axis=0), dep_t[:-1], label="Model") |
673 |
| - ax.plot(np.nanmean(velo, axis=1), dep[:], label="Observations") |
674 |
| - ax.plot( |
675 |
| - np.nanmean(lastvel, axis=0), dep_t[-2:], "--b", label="Bottom grid cell" |
676 |
| - ) |
677 |
| - ax.set_xlabel("Daily averaged velocity [m/s]", **axis_font) |
678 |
| - ax.set_ylabel("Depth [m]", **axis_font) |
679 |
| - axis_colors(ax, "gray") |
680 |
| - ax.set_title(f"{direc} velocities at VENUS {station}", **title_font) |
681 |
| - ax.grid() |
682 |
| - ax.set_ylim(profile) |
683 |
| - ax.set_xlim([-0.5, 0.5]) |
684 |
| - ax.invert_yaxis() |
685 |
| - ax1.legend(loc=0) |
686 |
| - |
687 |
| - return fig |
688 |
| - |
689 |
| - |
690 |
| -## TODO: Move/rename to figures.comparison as adcp_depth_avg module |
691 |
| -def plotdepavADCP(grid_m, grid_o, day, station): |
692 |
| - """This function plots a comparison of the depth averaged velocities of |
693 |
| - the model and the observations. |
694 |
| -
|
695 |
| - :arg grid_m: The model grid |
696 |
| - :type grid_m: netCDF4 dataset. |
697 |
| -
|
698 |
| - :arg grid_o: The observational grid |
699 |
| - :type grid_o: dictionary |
700 |
| -
|
701 |
| - :arg day: day of interest |
702 |
| - :type day: datetime object |
703 |
| -
|
704 |
| - :arg station: Station of interest. Either 'Central' or 'East' or 'ddl' |
705 |
| - :type station: string |
706 |
| -
|
707 |
| - :return: fig |
708 |
| - """ |
709 |
| - if station == "Central": |
710 |
| - profile = [40, 270] |
711 |
| - elif station == "East": |
712 |
| - profile = [30, 150] |
713 |
| - else: |
714 |
| - profile = [25, 130] |
715 |
| - |
716 |
| - # Get grids into unstaggered and masked velocities at the chose depths |
717 |
| - u_E, v_N, dep_t = load_vel(day, grid_m, "model", station, profile) |
718 |
| - u, v, dep = load_vel(day, grid_o, "observation", station, profile) |
719 |
| - |
720 |
| - # Depth averaging center of water column |
721 |
| - uE_av = analyze.depth_average(u_E, dep_t, 1) |
722 |
| - vN_av = analyze.depth_average(v_N, dep_t, 1) |
723 |
| - u_av = analyze.depth_average(u, dep[::-1], 0) |
724 |
| - v_av = analyze.depth_average(v, dep[::-1], 0) |
725 |
| - |
726 |
| - # Begin figure |
727 |
| - fig, ([ax1, ax2]) = plt.subplots(2, 1, figsize=(15, 10), sharex=True) |
728 |
| - fig.patch.set_facecolor("#2B3E50") |
729 |
| - |
730 |
| - # Setting the date for title |
731 |
| - date = day.strftime("%d%b%y") |
732 |
| - |
733 |
| - timestep = 0.5 |
734 |
| - velocities = [uE_av, vN_av] |
735 |
| - veloobs = [u_av, v_av] |
736 |
| - axes = [ax1, ax2] |
737 |
| - direction = ["East/West", "North/South"] |
738 |
| - |
739 |
| - for ax, vel, velo, direc in zip(axes, velocities, veloobs, direction): |
740 |
| - ax.plot(np.arange(0, 24, timestep / 2), vel, label="Model") |
741 |
| - ax.plot(np.arange(0.25, 24, timestep), velo, label="Observations") |
742 |
| - ax.set_xlim([0, 24]) |
743 |
| - ax.set_ylabel("Velocity [m/s]", **axis_font) |
744 |
| - axis_colors(ax, "gray") |
745 |
| - ax.set_title( |
746 |
| - f"Depth Averaged ({profile[0]}-{profile[1]}m) {direc} velocities " |
747 |
| - f"at VENUS {station} -{date}", |
748 |
| - **title_font, |
749 |
| - ) |
750 |
| - ax.grid() |
751 |
| - ax.set_ylim([-0.6, 0.6]) |
752 |
| - ax1.legend(loc=0) |
753 |
| - ax2.set_xlabel("Hour [UTC]") |
754 |
| - |
755 |
| - return fig |
756 |
| - |
757 |
| - |
758 | 532 | def plot_ellipses(
|
759 | 533 | params, x, y, depth="None", numellips=1, imin=0, imax=398, jmin=0, jmax=898
|
760 | 534 | ):
|
761 | 535 | """Plot ellipses on a map in the Salish Sea.
|
762 | 536 | :arg params: a array containing the parameters (possibly at different
|
763 |
| - depths and or locations).The parameters must have 0 as major axis, |
764 |
| - 1 as minor axis and 2 as inclination |
765 |
| - :type param: np.array |
| 537 | + depths and or locations).The parameters must have 0 as major axis, |
| 538 | + 1 as minor axis and 2 as inclination |
| 539 | + :type params: np.array |
766 | 540 |
|
767 | 541 | :arg x: Horizontal index of the location at which the ellipse should be
|
768 |
| - positioned. Should have equal or more values than numellips. |
| 542 | + positioned. Should have equal or more values than numellips. |
769 | 543 | :type x: float or np.array
|
770 | 544 |
|
771 | 545 | :arg y: Vertical index of the location at which the ellipse should be
|
772 |
| - positioned. Should have equal or more values than numellips. |
| 546 | + positioned. Should have equal or more values than numellips. |
773 | 547 | :type y: float or np.array
|
774 | 548 |
|
775 | 549 | :arg depth: The depth at which you want to see the ellipse. If the param
|
776 |
| - array has no depth dimensions put 'None'. Default 'None'. |
| 550 | + array has no depth dimensions put 'None'. Default 'None'. |
777 | 551 | :arg depth: int
|
778 | 552 |
|
779 | 553 | :arg numellips: Number of ellipse that will be plotted from the params
|
780 |
| - array. If =1 the function assumes there is no locations dimensions, |
781 |
| - only parameter and possibly depth if notified. |
| 554 | + array. If =1 the function assumes there is no locations dimensions, |
| 555 | + only parameter and possibly depth if notified. |
782 | 556 | :type numellips: int
|
783 | 557 |
|
784 | 558 | :arg imin: Minimum horizontal index that will be plotted.
|
@@ -898,11 +672,11 @@ def plot_ellipses_area(
|
898 | 672 | ):
|
899 | 673 | """Plot ellipses on a map in the Salish Sea.
|
900 | 674 | :arg params: a array containing the parameters (possibly at different
|
901 |
| - depths and or locations). |
902 |
| - :type param: np.array |
| 675 | + depths and or locations). |
| 676 | + :type params: np.array |
903 | 677 |
|
904 | 678 | :arg depth: The depth at which you want to see the ellipse. If the param
|
905 |
| - array has no depth dimensions put 'None'. Default 'None'. |
| 679 | + array has no depth dimensions put 'None'. Default 'None'. |
906 | 680 | :arg depth: int
|
907 | 681 |
|
908 | 682 | :arg imin: Minimum horizontal index that will be plotted.
|
|
0 commit comments