-
Notifications
You must be signed in to change notification settings - Fork 8
5. Plots and reports
- Select the layer obs_p_w_strat (or layer obs_points if you know which observation points that have stratigraphy data)
- Select the observation points you want to be plotted
- Choose Midvatten - View plots - Plot Stratigraphy (or click the button on the toolbar)
- In the result dialog, the user may choose to plot color depending on geology or well capacity ("hydro"). If the values in the stratigraphy table fields "geoshort" and "capacity" are corresponding to the values found in the data domains zz_strat and zz_capacity (described on the page data domains/dictionaries) then the plotting colors and fill patterns will be as shown in the figure above. The user may also select wether to plot geologic description, comments or no text at all.
- The colors and patterns in the plot can be changed by updating the fields "color_qt" and "brush_qt" in the data domain tables "zz_strat" and "zz_capacity".*
- You may also use additional codes for geology and well capacity to represent your local geological conditions. Simply put abbreviations and codes into fields "geoshort" and "hydro" in the stratigraphy table. Then update the data domain tables "zz_strat" and "zz_capacity" correspondingly (fields "geoshort"("strat") and "hydro").*
*Here is description of how to load these data domain tables to QGIS and here is a description of how they are related to the stratigraphy plot.
-
Select the table and column for time series plot: Midvatten - Midvatten Settings:
- eg Time Series - Table = w_levels, Column = levels_masl, Dot Markers on line
- or Time Series - Table = w_qual_lab_ph, Column = reading_num
- or Time Series - Table = w_levels_logger, Column = level_masl
- or Time Series - Table = w_flow, Column = reading **
-
Select the layer corresponding to the time series, such obs_p_w_lvl, obs_p_w_qual_lab, obs_p_w_flow (not by default) *
-
Choose observation points corresponding to the time series you want to be plotted
-
Choose Midvatten - View plot - Time Series Plot (or click the button on the toolbar)
* You can also select the layer obs_points and yourself keep track of which objects that have time series data _** Depending on the number of flow meters used and the types of readings taken, it may be necessary to create subsets of this table. _
- Select the table and column for xy scatter plot: Midvatten - Midvatten Settings: e.g. XY Scatter - Table = seismic_data, x-column = length, y1-columne = bedrock, y2-column = ground
- Select the layer corresponding to the xy scatter plot data, e.g. for seismic data select obs_lines
- Choose objects corresponding to the data you want to be plotted
- Choose Midvatten - View plot - Scatter Plot (or click the button on the toolbar)
- To use this feature, it is absolutely necessary that your database table "w_qual_lab" includes the Base Cat- and An-ions, as listed below, in mg/l.
- Select the parameter text strings that corresponds to the necessary parameters (Chloride, Alcalinity, Sulfate, Natrium, Potassium, Calcium and Magnesium): Midvatten - Midvatten Settings - Tab Piper diagram:
NOTE! If the fields Cl-Mg above are left empty, then the plugin will try to create a piper diagram under assumption of:
the value field represents chloride (mg/l) if parameter text string includes '%klorid%' or '%chloride%'
the value field represents alcalinity (mg/l) if parameter text string includes '%alkalinitet%' or '%alcalinity%'
the value field represents sulphate (mg/l) if parameter text string includes '%sulfat%' or '%sulphat%'
the value field represents natrium (mg/l) if parameter text string includes '%natrium%'
the value field represents potassium (mg/l) if parameter text string includes '%kalium%' or '%potassium%'
the value field represents calcium (mg/l) if parameter text string includes '%kalcium%' or '%calcium%'
the value field represents magnesium (mg/l) if parameter text string includes '%magnesium%'
3. Select if you want unique markers for obsid, obs type, date etc. (see the "Markers unique for" combobox in the figure above)
4. Choose objects corresponding to the data you want to be plotted (Using the layer obs_p_w_qual_lab is recommended but not mandatory.)
5. Choose Midvatten - View plot - Piper diagram (or click the button on the toolbar)
(Higher res. image)
6. Remember, this feature is primarily meant for quick access to data, not for final reports.
Hidden feature: extract piper diagram plot data
If you want to make your own piper diagram with full control of legend and layout, then open the python console (Plugins - Python Console) prior to choosing Midvatten - View plot - Piper diagram. The output in the python console can be copied and pasted into any spreadsheet for further analysis in your own software (click image to enlarge):
(Higher res. image)
Please note! This feature assumes that projected coordinate reference systems are used (it will not work with tutorial data where CRS=EPSG 4326). It is also highly recommended to use the same Coordinate Reference System (CRS) for both the project and all involved layers.
New in version 1.6.2:
- New ui for sectionplot. Settings now located in separate tab. The settings tab can be floated and moved also.
- If no section line is selected, Sectionplot now plots like the Stratigraphyplot. (Thanks to Simon O'Connor!)
- Capacity colors can now be used in the same way as Stratigraphyplot. (Thanks to Simon O'Connor!)
- Hydroexplanation (capacity explanation) can now be used as text for layers. (Thanks to Simon O'Connor!)
- Sectionplot can now (hopefully) be maximized. (Thanks to Simon O'Connor!)
- Plotsize now set in template in inches in "rcParams": {"figure.figsize": [6.4, 4.8]} and by checking radiobutton Plotsize: "Fixed".
- Sectionplot can now be used with one obsid. No longer limited to more than one.
- Sectionplot can now be used with only a selected line layer (for plotting DEMS and seismic).
- Removed redraw button. Legend updates automatically when clicking NavigationToolbar Apply button.
- Activate obs_points layer and the select the observations that you want to be included in section plot (
You must select at least two points to get a section plot. //Version 1.6.2 and onwards has resolved this issue) - Select any polyline layer that describes your section and select exactly one (1) feature in this layer. ACTIVATE THIS LAYER Please notice: if you want to plot DEM(s) in your profile. This polyline layer and the DEM(s) must have the same CRS.
- Select Midvatten - View plot - Plot Section (or click the button on the toolbar). Then you get a docked panel with section plot (click image to enlarge): (Higher res. image)
The image above is from a development version of plugin, the one below shows section plot from version 1.1.12
and the next screendump is a section plot without stratigraphy, good for studying water level profiles:
(Higher res. image)
The colors and patterns ("hatches") for stratigraphy are defined by the data domain zz_strat which is described on the page data domains/dictionaries. Update this table to change colors and patterns.
In the left hand panel there are a few options that may be selected to alter your plot:
- Select water level table and dates to be plotted in the section (the plugin will search for first the observations that match the date-time strings, so you may simply write "2014" to get the first water level measurements for year 2014)
- Select your DEM(s) from the list of visible single band raster layers (with same CRS as the polyline layer and the qgis project)
- Check/uncheck "Stratigraphy" check box to hide/show the stratigraphy plot (thus enable a section plot witn only water level or DEM info along the section)
- Check/uncheck "Labels" check box to hide/show obsid for each observation point
- Select text to be plotted beside each stratigraphy layer
- Adjust column width as desired (% of full distance)
- Indicate Drill stop: Type a string corresponding to the drill stop type you want to indicate in your plot this string is compared to the field drillstop in your obs_points table you may use % as wild card example: %bedrock% ((This is not case sensitive, the sqlite clause is: select where lower(drillstop) like 'yourstringhere'))
- Then click "replot"
Hidden feature: add seismic data to your plot
If your selected polyline layer is obs_lines in the Midvatten database and there are some seismic data for the selected polyline feature (stored in the table seismic_data in Midvatten db). Then the corresponding values for "ground" and "bedrock" will be plotted to the section plot. (Make sure your polyline feature direction corresponds to the "length" values in table seismic_data or else your plot will be reversed).
Grouped water level plots
(introduced in plugin version 1.5)
Plotted water levels (step 1. above) for the chosen dates can be grouped by adding a list of obsids after the date, ex:
YYYY;obsid1;obsid2
XXXX;obsid3;obsid4
This is useful for creating separate water level plots for observations of different types, for example surface water and ground water wells.
Hidden feature: export length along section values for use in another application [CURRENTLY UNAVAILABLE]
If you open the QGIS python console prior to creating the section plot, then you will get the "distance along section" for all selected observation points printed to the console. It may be useful if you want to make corresponding section plots in another application.
(introduced in version 1.5)
- Feature to give the user much more freedom for customizing the plot and saving the customization as templates.
- Many of the python Matplotlib plot methods support keyword arguments for customizing the plot. New functionality in section plot allows these keywords to be used for a lot of the plot functions.
- Templates (regular text files) can be imported, loaded and saved.
- Version 1.5 of the plugin includes 4 predefined templates.
- To load an imported template, select the template in the list, click "Load" and then "Replot".
- When the loaded template is edited, it is not automatically saved to file. Use "Save as..." to save the changes to file.
Edit the loaded template:
- Click "Edit".
- Copy the supplied string into a text editor of choice. NOTE: The default settings contain all the currently supported methods, but only a small portion of the available arguments. See notes below about keyword arguments. It will look something like this (this is only a fraction of the settings) :
{
"Axes_set_xlabel": {
"fontsize": 10,
"xlabel": u"Distance along section"},
"Axes_set_xlim": None,
"Axes_set_ylabel": {
"fontsize": 10,
"ylabel": u"Level, masl"},
"Axes_set_ylim": None,
"Figure_subplots_adjust": {
},
"dems_Axes_plot": {
"DEFAULT": {
"linestyle": "-",
"linewidth": 1,
"marker": "None"},
...
- Change the settings already there, or add new settings.
- Copy the settings back from text editor into the line edit.
- Click "Replot" (You may also try "Redraw" but it will not update all of your customizations)
Notes:
- The customization string is saved in the QGis project and can be saved to file using "Save as...".
- The string will be converted as is into python code. That means that {} is a dictionary, [] a list, "" a string, 1 an integer and so on. There are no syntactic checks. If the string is not convertable to python dict or nonexisting keyword arguments are given, the result will be a python error.
- Strings containing special characters like åäö must be preceded by u to be handled as unicode. Ex: "label": u"åäö".
- The majority of the settings are named like prefix_Class_method. The Class will always be capitalized. The prefix gives a clue about what the settings belong to.
- Supported settings for each Class_method can be found using your search engine of choice with a search like "Matplotlib Class method". Ex: "Matplotlib Axes legend". Look for a page containing the "matplotlib.axes.Axes.legend"-string and the "Axes.legend(*args, **kwargs)"-string. The keyword arguments are found at the "Parameters:"-string.
- Adjust the plot padding using
"Figure_subplots_adjust" = {"top": 0.95, "bottom": 0.15, "left": 0.09, "right": 0.97}
- Plotsize is set in template in inches in
"rcParams": {"figure.figsize": [6.4, 4.8]}
and by checking radiobutton Plotsize: "Fixed". A plotsize of 6.4 by 4.8 works well for Libre Office. - The bar linewidths for the full stratigraphy "bar" is changed using "obsid_Axes_bar": {"linewidth": 0.5}.
- Notes on water levels plotting (wlevels_Axes_plot): If the same date is given more than once, an order suffix is automatically added to all but the first in the wlevels_Axes_plot settings. Ex:
date_time f w level:
2017-01-01
2017-01-01
2017-01-01
will result in wlevels_Axes_plot{"2017-01-01" ..., "2017-01-01_2"..., "2017-01-01_3"...}
in the same order as the list.
This is intended.
- Notes on dems plotting (dems_Axes_plot): Works just as the water levels plotting above, but will usually not occur. (dems usually have unique names).
- Notes on legend fontsizes:
"legend_Text_set_fontsize" sets the fontsize for the text in the legend.
"legend_Axes_legend": {"fontsize": 10}
sets the size of the handles (the geology "figures") in the legend.
-
select Midvatten - Midvatten Settings - Tab W quality report and make selections according to your data (default settings: Table = w_qual_lab, parameter name = parameter value = reading_txt Analysis)
-
Select the layer obs_p_w_qual_lab
-
Select the obs_points to generate a report
-
Select Midvatten - View report - Water Quality Report (or click the button on the toolbar)
-
The result is displayed in your default internet browser. The table can be highlighted, copied and pasted into Excel or Word
Notes:
- The report prints one of all values matching the user specified "Unique date_time format". This value is not necessarily the oldest or most recent value of all values matching the format!
Feature for exporting water quality from w_qual_lab in a compact format for report attachments spanning multiple report pages. The feature produces table that is assumed to be copied into a word processor. Water quality data is sorted by obsid and date_time and split into multiple tables. Each table contains a user specified number of columns which is chosen with regard to the report page size (A4/A3/landscape/portrait).
The format of each table is hard coded to:
obsid | obs1 | obs1 | obs2 |
---|---|---|---|
date_time | 2018-01-01 11:00 | 2018-01-02 12:00 | 2018-01-01 11:00 |
report | 0001 | 1002 | 2003 |
Par1, unit1 | 1.34 | <10 | |
Par2, unit2 | 5.67 | 565 |
HOWTO:
-
Choose data to be included. This can be done in 3 or more ways:
a) Create report for chosen obsids: Select "Data from selected obsids in sql table" and choose w_qual_lab in the dropdown list. QGIS layer containg the column obsid and select some obsids.
b) Create reports with more filters than obsid: Create an sql view in the database to create a customized filter containing the rows to export. Choose the view from the dropdown list. Then choose obsids in the same way as a) above.
c) Create reports with more filter than obsid using QGIS database manager: Use QGIS database manager to create QGIS layers containg the columns 'obsid', 'date_time', 'report', 'parameter', 'unit', 'reading_txt'. Select "Data from selected features in active layer". Then select the layer in QGIS layer list and select features in that layer to be used. This is similar to step b) above but doesn't create database views. !!NOTE!! For some reason, layers created in this way sometimes produces "invalid" features which isn't included in the report. Handle with care!
-
Chose Number of data cols. This sets the maximum number of data columns each table can contain before splitting up into more tables.
-
Set Rowheader colwidth %. Sets the width of the "Parameter, unit" column..
-
Chose layout for the tables. One layout produces one large table with the advantage of being as compact as possible and easier for chaning table settings. The other layout produces separate tables, one per page. The advantage is that headers always appear at the top of the page. Disadvantage is that settings for the tables often has to be done manually for each table, which can be time consuming.
a) Selecting "Page break between tables" produces a layout with one table per report page.
b) Selecting deselecting both "Empty row between tables" and "Page break between tables" produces one long table with reocurring headers and no spaces between previous data value and new header.
c) Selecting "Empty row between tables" produces same table as in b) but with the string empty_row_between_tables between the tables that can be turned into an empty row using find and replace. -
Click "Ok" and copy the tables from the browser into a word processor of choice.
Notes:
- There seem to be compability issues between this report, Google Chrome and copy/paste to Libre office. Opening the report using Mozilla Firefox worked better.
- The data is extracted from the column 'reading_txt' from the chosen table/layer.
- Select the layer obs_points
- Select one or more obs_point(s)
- Select Midvatten - View report - General Report (or click the button on the toolbar)
- The result is displayed in your default internet browser. The table can be highlighted, copied and pasted into Excel or Word.
(Higher res. image)
(introduced in plugin version 1.5)
This report creates a report similar to the general report, but allowes more customization. The report is useful for creating LibreOffice writer importable tables in an easy way.
Features includes:
- Specify fields to put in the output tables.
- Width of the tables.
- Rounding of float-values.
- Font size of the headers and table items (see notes below).
- Specifying columns for stratigraphy table.
- Include or exclude comments.
- Select the layer obs_points
- Select one or more obs_point(s)
- Select Midvatten - View report - Custom general report to open the gui:
- Specify which columns from table obs_points to include in the "Top left metadata table" and "Top right metadata table". See tooltip for information about rounding of values.
- Specify stratigraphy columns to include in the stratigraphy table in "Stratigraphy columns". See tooltip for information about adjusting column widths. "depth" is a special keyword, see tooltip.
- Adjust the other settings as needed.
- Click "Ok" to plot.
Notes:
- Most of the settings show tooltips (by placing mouse pointer over the setting). That explains the setting
- Adjusting fontsizes: The fontsizes are adjustable by setting LibreOffice hmtl-import fontsizes (Tools - Options' - Load/Save - HTML Compatibility'.). Table text is written as size 1. Stratigraphy table header is size 2. The headers above each table is size 3. The obsid is size 4.
- The settings are saved in the QGis project. They can also be accessed using the button "Update settings from string" and can thus be stored or altered elsewhere.
- Make sure your database is selected in Midvatten settings
- Select Midvatten - View plot - Custom plots:
Custom plot version 1.4 (Higher res. image)
(Older version of custom. The referenced features still exists)
(Higher res. image)
(Older version of custom. The referenced features still exists)
In the new window:
a. Using Tab 1 - Tab 3 lets you plot from up to 3 different tables simultaneously, for each "Tab" do:
b. Select Table and columns for x- and y-axis
c. Set up to two filters
d. Select plot type (see note below about frequency plots)
e. If you want discontinuous plots, set step > 0 (in days or the corresponding unit from x-axis column)
f. Press "Plot chart" - Depending on your selection this may take some time...
g. set titles as you want
h. activate to show legend and grid
i. normally you would just zoom manually and drag to legend to desired position but this area (i) lets you fine-tune axis ranges and legend position. whenever all values are set to zero, then there will be autoscaling and legend placement
i2. press the "figure options" button to change appearance of labels, plots and more (please notice that this might break your date-time format on the xaxis but it will be fixed in next step)
j. press "Redraw" to update your plot according to selections g.-i. (and fix the broken xaxis format caused by step i2)
Notes:
- New in 1.4: Python Pandas features resample and rolling mean can be applied to the plots if pandas is correctly installed (It must be importable by QGis). For linux this is usually as easy as "sudo apt-get install python-pandas". Installing Pandas using Windows is harder but doable and has been discussed a bit here: https://github.com/jkall/qgis-midvatten-plugin/issues/178
Generate frequency plots on-the-fly from pulse counts
There is an option of plotting frequency on-the-fly from a dataset with pulse counts. This feature is activated if "plot type"="frequency" is selected. Then the selected data series is divided by time step between observations (in seconds) and plotted as a frequency (which is indicated in the legend). Hence you may keep pulses in the database and directly plot them as frequency in Hz. You may also plot water flow, stored as accumulated volume (m3), as average flow (m3/s) directly with help from this feature.