jkall / qgis-midvatten-plugin

Midvatten plugin for QGIS
23 stars 8 forks source link

date time #330

Closed spesty closed 3 years ago

spesty commented 3 years ago

Hi I was wondering if you might be able to assist with a date time error I keep getting. this is happening with the tutorial data and also my own. see error log

image

can you advise if I need to change a setting. I have tried the import for water levels for both mysql and postgres but no luck!

cheers Darryl

HenrikSpa commented 3 years ago

Hi! The problem is that your date format is not supported. Your date "28/11/2012 10:55" translates to format "%d/%m/%Y %H:%M" which is not included in the list of supported formats (see the error message).

You could either change your date format in your files or add support for your format to the plugin:

1) Open Settings>User Profiles>Open Active Profile Folder. 2) From the profile folder, go to python\plugins\midvatten\tools and open the file _dateutils.py in a text editor. 3) In the file, go to the function _find_dateformat and look for the list _date_formats_totry. 4) Add your format '%d/%m/%Y %H:%M' at the end of the list. Ex:

... '%d.%m.%Y %H:%M', '%d.%m.%Y %H:%M:%S', '%d/%m/%Y %H:%M']

5) Restart QGIS (sometimes it needs to be restarted twice in a row for the change to take effect).

HenrikSpa commented 3 years ago

I assume the date 28/11/2012 is indeed 28:th of November 2012 and not an error like 11:th of the "28:th month" 2012.

spesty commented 3 years ago

Hi

thanks for the direction. you are correct with the date its 28th Nov 2012. I will try and make an adjustment to the code as recommended and re-try. If that doesnt work I will try and re-format the data - although using excel to create the csv seems to default to Australian datetime.

Cheers DArryl


From: HenrikSpa @.> Sent: Thursday, 6 May 2021 5:53 PM To: jkall/qgis-midvatten-plugin @.> Cc: spesty @.>; Author @.> Subject: Re: [jkall/qgis-midvatten-plugin] date time (#330)

I assume the date 28/11/2012 is indeed 28:th of November 2012 and not an error like 11:th of the "28:th month" 2012.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjkall%2Fqgis-midvatten-plugin%2Fissues%2F330%23issuecomment-833312715&data=04%7C01%7C%7C029522ee2cf749eeb09508d910640c98%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637558844157993696%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=kBZA49X7zdT31BsgS5iDWwvTmvtryRA2w%2FUsWyBKkes%3D&reserved=0, or unsubscribehttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FASUPDYVGPKALTNXR3RHVHSLTMJDH3ANCNFSM44GO7RVQ&data=04%7C01%7C%7C029522ee2cf749eeb09508d910640c98%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637558844157993696%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=pqL%2BBqA5lKdcsEk7Rs2MCiJC27hA%2F2I2sWZ8D%2FTOxLI%3D&reserved=0.

spesty commented 3 years ago

Hi

I just wanted to follow up and mentioned I got the date format to work. Thanks for the support.

I was wondering if you can provide any guidance on the best way to get up to speed with code and adding a few components to the plugin? Its really good but I would like to include a few additional plots and survey data. Is there also a way of dealing with nested monitoring bores - were there obsid is the same but the name is different?

Cheers Darryl


From: Darryl West @.> Sent: Friday, 7 May 2021 9:53 AM To: jkall/qgis-midvatten-plugin @.>; jkall/qgis-midvatten-plugin @.> Cc: Author @.> Subject: Re: [jkall/qgis-midvatten-plugin] date time (#330)

Hi

thanks for the direction. you are correct with the date its 28th Nov 2012. I will try and make an adjustment to the code as recommended and re-try. If that doesnt work I will try and re-format the data - although using excel to create the csv seems to default to Australian datetime.

Cheers DArryl


From: HenrikSpa @.> Sent: Thursday, 6 May 2021 5:53 PM To: jkall/qgis-midvatten-plugin @.> Cc: spesty @.>; Author @.> Subject: Re: [jkall/qgis-midvatten-plugin] date time (#330)

I assume the date 28/11/2012 is indeed 28:th of November 2012 and not an error like 11:th of the "28:th month" 2012.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjkall%2Fqgis-midvatten-plugin%2Fissues%2F330%23issuecomment-833312715&data=04%7C01%7C%7C029522ee2cf749eeb09508d910640c98%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637558844157993696%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=kBZA49X7zdT31BsgS5iDWwvTmvtryRA2w%2FUsWyBKkes%3D&reserved=0, or unsubscribehttps://apac01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FASUPDYVGPKALTNXR3RHVHSLTMJDH3ANCNFSM44GO7RVQ&data=04%7C01%7C%7C029522ee2cf749eeb09508d910640c98%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637558844157993696%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=pqL%2BBqA5lKdcsEk7Rs2MCiJC27hA%2F2I2sWZ8D%2FTOxLI%3D&reserved=0.

HenrikSpa commented 3 years ago

Hi!

You are very welcome to contribute to the plugin!

I'm not sure how familiar you are with python/SQL/Qt5/QGIS api, but here are some short remarks as a start:

Example 1, for sparse queries. Connect to database, get data and close connection in one function:

from db_utils import sql_load_fr_db
query_result = sql_load_fr_db('''SELECT obsid, date_time, level_masl FROM w_levels''')[1]

Example 2, for many queries without connecting and disconnecting from the database after each statement:

from db_utils import DbConnectionManager
dbconnection = db_utils.DbConnectionManager()
query_result = dbconnection.execute_and_fetchall('''SELECT obsid, date_time, level_masl FROM w_levels''')
dbconnection.closedb()

Then you can do what you want with the data in query_result, for example plotting using matplotlib.

If you explain your coding background and what kind of plots you want to create maybe I can point you in the right direction.

Regards, Henrik

HenrikSpa commented 3 years ago

About your second question:

Is there also a way of dealing with nested monitoring bores - were there obsid is the same but the name is different?

I'm not sure how you mean.

We often come across bores that share names, for example "Well 1". For these cases we add prefixes or suffixes to the name so it becomes a unique obsid in obspoints (ex. Well1). The same well can sometimes have many names in many different reports. Then we choose one of them as obsid, and the other names are put as comma separated list in the name column in table obs_points.

HenrikSpa commented 3 years ago

One more thing.

To make changes, clone the repository to your own git, make changes and create pull requests to this repository.

I usually use the branch _qgis3henrik for all my latest changes, and sometimes separate branches for specific features. The master branch is the latest stable bransch, but could lack features compared to _qgis3henrik. It's probably best if you base your changes on the _qgis3henrik branch and make a new bransch with your new features.