Skip to content

Commit 952a42e

Browse files
authoredMay 11, 2019
Merge pull request #174 from ODM2/development
Merge development into master to issue new 0.72 release. See #165
2 parents 7a1e899 + c6782b5 commit 952a42e

14 files changed

+4302
-4313
lines changed
 

‎Examples/TimeSeries_RetrieveVisualize.ipynb

+17-27
Large diffs are not rendered by default.

‎Examples/WaterQualityMeasurements_RetrieveVisualize.ipynb

+25-29
Large diffs are not rendered by default.

‎Examples/clientenvironment.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ dependencies:
77
- yodatools
88
- requests
99
- scipy
10-
- xarray
11-
- folium
1210
- geopandas
13-
- gdal=2.2
14-
- owslib
15-
- ulmo
11+
- gdal
12+
- folium
1613
# Jupyter notebook
1714
- ipykernel
1815
- jupyter

‎docs/source/getstarted.rst

+15-15
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ To create a new environment "myenv" with the ``odm2api`` package:
4949

5050
conda create -n myenv -c conda-forge python=2.7 odm2api
5151

52+
Sample Jupyter notebooks
53+
------------------------
54+
55+
These two notebooks are complete, extended examples that illustrate reading from ODM2 databases and using the resulting data and metadata. They use SQLite ODM2 file databases that can be `downloaded here <https://github.com/ODM2/ODM2PythonAPI/tree/master/Examples/data>`_.
56+
A conda environment to run these notebooks can be created with the conda environment file
57+
`clientenvironment.yml <https://github.com/ODM2/ODM2PythonAPI/blob/master/Examples/clientenvironment.yml>`_.
58+
59+
1. `WaterQualityMeasurements_RetrieveVisualize.ipynb <https://nbviewer.jupyter.org/github/ODM2/ODM2PythonAPI/blob/master/Examples/WaterQualityMeasurements_RetrieveVisualize.ipynb>`_
60+
61+
2. `TimeSeries_RetrieveVisualize.ipynb <https://nbviewer.jupyter.org/github/ODM2/ODM2PythonAPI/blob/master/Examples/TimeSeries_RetrieveVisualize.ipynb>`_
5262

5363
Code examples
5464
-------------
@@ -63,12 +73,14 @@ Connect to an ODM2 database and open the connection for reading.
6373
from odm2api.ODMconnection import dbconnection
6474
import odm2api.services.readService as odm2rs
6575
66-
# A SQLite file-based connection
76+
# -----------------------------------------------------
77+
# 1. A SQLite file-based connection
6778
session_factory = dbconnection.createConnection('sqlite',
6879
'/myfilepath/odm2db.sqlite')
6980
read = odm2rs.ReadODM2(session_factory)
7081
71-
# A connection to a server-based database system
82+
# -----------------------------------------------------
83+
# 2. A server-based database system connection
7284
db_credentials = {
7385
'address': 'ip-or-domainname',
7486
'db': 'dbname',
@@ -93,21 +105,9 @@ then constructing and issuing a direct ``SQL UPDATE`` statement, like this:
93105
from odm2api.ODMconnection import dbconnection
94106
95107
session_factory = dbconnection.createConnection('postgresql',
96-
**db_cred)
108+
**db_credentials)
97109
DBSession = session_factory.getSession()
98110
99111
sq_str = " UPDATE mytable SET variablecode = 'xyz' WHERE variablecode = 'abc' "
100112
DBSession.execute(sql_str)
101113
DBSession.commit()
102-
103-
104-
Sample Jupyter notebooks
105-
------------------------
106-
107-
These two notebooks are complete, extended examples that illustrate reading from ODM2 databases and using the resulting data and metadata. They use SQLite ODM2 file databases that can be `downloaded here <https://github.com/ODM2/ODM2PythonAPI/tree/master/Examples/data>`_.
108-
A conda environment to run these notebooks can be created with the conda environment file
109-
`clientenvironment.yml <https://github.com/ODM2/ODM2PythonAPI/blob/master/Examples/clientenvironment.yml>`_.
110-
111-
1. `WaterQualityMeasurements_RetrieveVisualize.ipynb <https://github.com/ODM2/ODM2PythonAPI/blob/master/Examples/WaterQualityMeasurements_RetrieveVisualize.ipynb>`_
112-
113-
2. `TimeSeries_RetrieveVisualize.ipynb <https://github.com/ODM2/ODM2PythonAPI/blob/master/Examples/TimeSeries_RetrieveVisualize.ipynb>`_

‎docs/source/index.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ ODM2 Python API (odm2api)
33

44
A Python-based application programmer's interface for the `Observations Data Model 2 (ODM2) <http://www.odm2.org>`__. Development of ``odm2api`` is done at `<https://github.com/ODM2/ODM2PythonAPI/>`_.
55

6+
Contents
7+
--------
8+
69
.. toctree::
710
:maxdepth: 2
8-
:caption: Contents:
911

1012
getstarted
1113
odm2models
@@ -14,7 +16,7 @@ A Python-based application programmer's interface for the `Observations Data Mod
1416
credits
1517

1618
Indices and Search
17-
==================
19+
-----------------
1820

1921
.. toctree::
2022
:maxdepth: 2

‎odm2api/models.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
BigIntegerType = BigIntegerType.with_variant(mysql.BIGINT(), 'mysql')
1515

1616
DateTimeType = DateTime()
17-
DateTimeType = DateTimeType.with_variant(sqlite.INTEGER(), 'sqlite')
17+
DateTimeType = DateTimeType.with_variant(sqlite.DATETIME(), 'sqlite')
1818

1919

2020
def is_hex(s):
@@ -463,7 +463,7 @@ class DataLoggerFiles(Base):
463463

464464

465465
class EquipmentModels(Base):
466-
ModelID = Column('modelid', Integer, primary_key=True, nullable=False)
466+
ModelID = Column('equipmentmodelid', Integer, primary_key=True, nullable=False)
467467
ModelManufacturerID = Column('modelmanufacturerid', Integer,
468468
ForeignKey(Organizations.OrganizationID), nullable=False)
469469
ModelPartNumber = Column('modelpartnumber', String(50))
@@ -537,14 +537,15 @@ class Equipment(Base):
537537
EquipmentCode = Column('equipmentcode', String(50), nullable=False)
538538
EquipmentName = Column('equipmentname', String(255), nullable=False)
539539
EquipmentTypeCV = Column('equipmenttypecv', ForeignKey(CVEquipmentType.Name), nullable=False, index=True)
540-
ModelID = Column('modelid', ForeignKey(EquipmentModels.ModelID), nullable=False)
541-
EquipmentSerialNumber = Column('equipmentseriealnumber', String(50), nullable=False)
540+
ModelID = Column('equipmentmodelid', ForeignKey(EquipmentModels.ModelID), nullable=False)
541+
EquipmentSerialNumber = Column('equipmentserialnumber', String(50), nullable=False)
542542
EquipmentInventoryNumber = Column('equipmentinventorynumber', String(50))
543543
EquipmentOwnerID = Column('equipmentownerid', ForeignKey(People.PersonID), nullable=False)
544544
EquipmentVendorID = Column('equipmentvendorid', ForeignKey(Organizations.OrganizationID), nullable=False)
545545
EquipmentPurchaseDate = Column('equipmentpurchasedate', DateTime, nullable=False)
546546
EquipmentPurchaseOrderNumber = Column('equipmentpurchaseordernumber', String(50))
547547
EquipmentDescription = Column('equipmentdescription', String(500))
548+
EquipmentDocumentationLink = Column('equipmentdocumentationlink', String(255))
548549

549550
PersonObj = relationship(People)
550551
OrganizationObj = relationship(Organizations)
@@ -580,7 +581,7 @@ class EquipmentUsed(Base):
580581

581582
class MaintenanceActions(Base):
582583
ActionID = Column('actionid', Integer, ForeignKey(Actions.ActionID), primary_key=True, nullable=False)
583-
IsFactoryService = Column('isfactoryservce', Boolean, nullable=False)
584+
IsFactoryService = Column('isfactoryservice', Boolean, nullable=False)
584585
MaintenanceCode = Column('maintenancecode', String(50))
585586
MantenanceReason = Column('maintenancereason', String(50))
586587

@@ -836,7 +837,7 @@ class ActionAnnotations(Base):
836837

837838
class EquipmentAnnotations(Base):
838839
BridgeID = Column('bridgeid', Integer, primary_key=True, nullable=False)
839-
EquipmentID = Column('valueid', BigIntegerType, ForeignKey(Equipment.EquipmentID), nullable=False)
840+
EquipmentID = Column('equipmentid', BigIntegerType, ForeignKey(Equipment.EquipmentID), nullable=False)
840841
AnnotationID = Column('annotationid', ForeignKey(Annotations.AnnotationID), nullable=False)
841842

842843
AnnotationObj = relationship(Annotations)
@@ -906,7 +907,7 @@ class ReferenceMaterials(Base):
906907
nullable=False,
907908
index=True
908909
)
909-
ReferenceMaterialOrganizationID = Column('referencematerialoranizationid',
910+
ReferenceMaterialOrganizationID = Column('referencematerialorganizationid',
910911
ForeignKey(Organizations.OrganizationID), nullable=False)
911912
ReferenceMaterialCode = Column('referencematerialcode', String(50), nullable=False)
912913
ReferenceMaterialLotCode = Column('referencemateriallotcode', String(255))
@@ -951,7 +952,7 @@ class ReferenceMaterialValues(Base):
951952

952953
class ResultNormalizationValues(Base):
953954
ResultID = Column(u'resultid', ForeignKey(Results.ResultID), primary_key=True)
954-
ReferenceMaterialValueID = Column(u'referencematerialvalueid',
955+
ReferenceMaterialValueID = Column(u'normalizedbyreferencematerialvalueid',
955956
ForeignKey(ReferenceMaterialValues.ReferenceMaterialValueID),
956957
nullable=False)
957958

@@ -1068,8 +1069,8 @@ class CitationExternalIdentifiers(Base):
10681069
ExternalIdentifierSystemID = Column('externalidentifiersystemid',
10691070
ForeignKey(ExternalIdentifierSystems.ExternalIdentifierSystemID),
10701071
nullable=False)
1071-
CitationExternalIdentifier = Column('citationexternaldentifier', String(255), nullable=False)
1072-
CitationExternalIdentifierURI = Column('citationexternaldentifieruri', String(255))
1072+
CitationExternalIdentifier = Column('citationexternalidentifier', String(255), nullable=False)
1073+
CitationExternalIdentifierURI = Column('citationexternalidentifieruri', String(255))
10731074

10741075
CitationObj = relationship(Citations)
10751076
ExternalIdentifierSystemObj = relationship(ExternalIdentifierSystems)
@@ -1678,7 +1679,7 @@ class SpectraResultValues(Base):
16781679
ValueDateTime = Column('valuedatetime', DateTimeType, nullable=False)
16791680
ValueDateTimeUTCOffset = Column('valuedatetimeutcoffset', Integer, nullable=False)
16801681
ExcitationWavelength = Column('excitationwavelength', Float(53), nullable=False)
1681-
EmissionWavelength = Column('emmistionwavelength', Float(53), nullable=False)
1682+
EmissionWavelength = Column('emissionwavelength', Float(53), nullable=False)
16821683
WavelengthUnitsID = Column('wavelengthunitsid', ForeignKey(Units.UnitsID), nullable=False)
16831684
CensorCodeCV = Column('censorcodecv', ForeignKey(CVCensorCode.Name), nullable=False, index=True)
16841685
QualityCodeCV = Column('qualitycodecv', ForeignKey(CVQualityCode.Name), nullable=False, index=True)

‎odm2api/services/readService.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def getAnnotations(self, annottype=None, codes=None, ids=None, **kwargs):
185185
a = Annotations
186186
self._check_kwargs(['type'], kwargs)
187187
if 'type' in kwargs:
188-
warnings.warn('The parameter \'type\' is deprecated. Please use the annottype parameter instead.',
188+
warnings.warn("The parameter 'type' is deprecated. Please use the annottype parameter instead.",
189189
DeprecationWarning, stacklevel=2)
190190
annottype = kwargs['type']
191191
if annottype:
@@ -238,7 +238,7 @@ def getCVs(self, cvtype, **kwargs):
238238
"""
239239
self._check_kwargs(['type'], kwargs)
240240
if 'type' in kwargs:
241-
warnings.warn('The parameter \'type\' is deprecated. Please use the cvtype parameter instead.',
241+
warnings.warn("The parameter 'type' is deprecated. Please use the cvtype parameter instead.",
242242
DeprecationWarning, stacklevel=2)
243243
cvtype = kwargs['type']
244244

@@ -430,7 +430,7 @@ def getMethods(self, ids=None, codes=None, methodtype=None, **kwargs):
430430
"""
431431
self._check_kwargs(['type'], kwargs)
432432
if 'type' in kwargs:
433-
warnings.warn('The parameter \'type\' is deprecated. Please use the medtype parameter instead.',
433+
warnings.warn("The parameter 'type' is deprecated. Please use the medtype parameter instead.",
434434
DeprecationWarning, stacklevel=2)
435435
methodtype = kwargs['type']
436436

@@ -517,7 +517,7 @@ def getSamplingFeatures(self, ids=None, codes=None, uuids=None,
517517
"""
518518
self._check_kwargs(['type'], kwargs)
519519
if 'type' in kwargs:
520-
warnings.warn('The parameter \'type\' is deprecated. Please use the sftype parameter instead.',
520+
warnings.warn("The parameter 'type' is deprecated. Please use the sftype parameter instead.",
521521
DeprecationWarning, stacklevel=2)
522522
sftype = kwargs['type']
523523
if results:
@@ -591,7 +591,7 @@ def getActions(self, ids=None, acttype=None, sfid=None, **kwargs):
591591
"""
592592
self._check_kwargs(['type'], kwargs)
593593
if 'type' in kwargs:
594-
warnings.warn('The parameter \'type\' is deprecated. Please use the acttype parameter instead.',
594+
warnings.warn("The parameter 'type' is deprecated. Please use the acttype parameter instead.",
595595
DeprecationWarning, stacklevel=2)
596596
acttype = kwargs['type']
597597
a = Actions
@@ -641,7 +641,7 @@ def getUnits(self, ids=None, name=None, unittype=None, **kwargs):
641641
"""
642642
self._check_kwargs(['type'], kwargs)
643643
if 'type' in kwargs:
644-
warnings.warn('The parameter \'type\' is deprecated. Please use the unittype parameter instead.',
644+
warnings.warn("The parameter 'type' is deprecated. Please use the unittype parameter instead.",
645645
DeprecationWarning, stacklevel=2)
646646
unittype = kwargs['type']
647647
q = self._session.query(Units)
@@ -779,7 +779,7 @@ def getResults(self, ids=None, restype=None, uuids=None, actionid=None, simulati
779779
query = self._session.query(Results)
780780
self._check_kwargs(['type', 'sfid'], kwargs)
781781
if 'type' in kwargs:
782-
warnings.warn('The parameter \'type\' is deprecated. Please use the restype parameter instead.',
782+
warnings.warn("The parameter 'type' is deprecated. Please use the restype parameter instead.",
783783
DeprecationWarning, stacklevel=2)
784784
restype = kwargs['type']
785785
if restype:
@@ -798,8 +798,8 @@ def getResults(self, ids=None, restype=None, uuids=None, actionid=None, simulati
798798
if actionid:
799799
query = query.join(FeatureActions).filter_by(ActionID=actionid)
800800
if 'sfid' in kwargs:
801-
warnings.warn('The parameter \'sfid\' is deprecated. '
802-
'Please use the sfids parameter instead and send in a list.',
801+
warnings.warn("The parameter 'sfid' is deprecated. " +
802+
"Please use the sfids parameter instead and send in a list.", # noqa
803803
DeprecationWarning, stacklevel=2)
804804
if kwargs['sfid']:
805805
query = query.join(FeatureActions).filter_by(SamplingFeatureID=kwargs['sfid'])
@@ -1087,7 +1087,7 @@ def getEquipment(self, codes=None, equiptype=None, sfid=None, actionid=None, **k
10871087
"""
10881088
self._check_kwargs(['type'], kwargs)
10891089
if 'type' in kwargs:
1090-
warnings.warn('The parameter \'type\' is deprecated. Please use the equiptype parameter instead.',
1090+
warnings.warn("The parameter 'type' is deprecated. Please use the equiptype parameter instead.",
10911091
DeprecationWarning, stacklevel=2)
10921092
equiptype = kwargs['type']
10931093

@@ -1191,7 +1191,7 @@ def getExtensionProperties(self, exptype=None, **kwargs):
11911191
# Todo what values to use for extensionproperties type
11921192
self._check_kwargs(['type'], kwargs)
11931193
if 'type' in kwargs:
1194-
warnings.warn('The parameter \'type\' is deprecated. Please use the exptype parameter instead.',
1194+
warnings.warn("The parameter 'type' is deprecated. Please use the exptype parameter instead.",
11951195
DeprecationWarning, stacklevel=2)
11961196
exptype = kwargs['type']
11971197
e = ExtensionProperties
@@ -1222,7 +1222,7 @@ def getExternalIdentifiers(self, eitype=None, **kwargs):
12221222
"""
12231223
self._check_kwargs(['type'], kwargs)
12241224
if 'type' in kwargs:
1225-
warnings.warn('The parameter \'type\' is deprecated. Please use the eitype parameter instead.',
1225+
warnings.warn("The parameter 'type' is deprecated. Please use the eitype parameter instead.",
12261226
DeprecationWarning, stacklevel=2)
12271227
eitype = kwargs['type']
12281228
e = ExternalIdentifierSystems
@@ -1415,9 +1415,9 @@ def getResultValues(self, resultids, starttime=None, endtime=None, lowercols=Tru
14151415
df.columns = [self._get_columns(ResultValues)[c] for c in df.columns]
14161416
else:
14171417
warnings.warn(
1418-
'In a near-future release, '
1419-
'the parameter \'lowercols\' default will be changed to False, '
1420-
'and later the parameter may be removed.',
1418+
"In a near-future release, " + # noqa
1419+
"the parameter 'lowercols' default will be changed to False, " +
1420+
"and later the parameter may be removed.", # noqa
14211421
DeprecationWarning, stacklevel=2)
14221422
return df
14231423
except Exception as e:
@@ -1487,7 +1487,7 @@ def getRelatedModels(self, modid=None, code=None, **kwargs):
14871487
"""
14881488
self._check_kwargs(['id'], kwargs)
14891489
if 'id' in kwargs:
1490-
warnings.warn('The parameter \'id\' is deprecated. Please use the modid parameter instead.',
1490+
warnings.warn("The parameter 'id' is deprecated. Please use the modid parameter instead.",
14911491
DeprecationWarning, stacklevel=2)
14921492
modid = kwargs['id']
14931493
m = self._session.query(Models).select_from(RelatedModels).join(RelatedModels.ModelObj)

‎tests/test_SessionFactory.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import (absolute_import, division, print_function)
22

3-
from odm2api.ODM2.models import CVElevationDatum, setSchema
43
from odm2api.ODMconnection import SessionFactory
4+
from odm2api.models import CVElevationDatum, setSchema
55

66
import pytest
77

@@ -15,10 +15,10 @@
1515
['mysql"root@Localhost/odm2', 'mysql', 'mysql+pymysql://root@localhost/odm2'],
1616
['postgresql_marchantariats_none', 'postgresql',
1717
'postgresql+psycopg2://postgres:None@localhost/marchantariats',
18-
'marchantariats', 'postgres', None],
18+
'marchantariats', 'postgres', None],
1919
['postgresql_marchantariats_empty', 'postgresql',
2020
'postgresql+psycopg2://postgres@localhost/marchantariats',
21-
'marchantariats', 'postgres', None],
21+
'marchantariats', 'postgres', None],
2222
['sqlite_wof', 'sqlite', 'sqlite:///./tests/spatialite/wof2odm/ODM2.sqlite', None, None, None]
2323
]
2424

‎tests/test_connection.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import (absolute_import, division, print_function)
22

3-
from odm2api.ODM2.models import CVElevationDatum
43
from odm2api.ODMconnection import dbconnection
4+
from odm2api.models import CVElevationDatum
55

66
import pytest
77

@@ -13,7 +13,7 @@
1313
dbs_readonly = [
1414
['mysql_odm2_odm', 'mysql', 'localhost', 'odm2', 'ODM', 'odm'],
1515
['mysql_odm2_root', 'mysql', 'localhost', 'odm2', 'root', None],
16-
['postgresql_marchantariats', 'postgresql', 'localhost', 'marchantariats', 'postgres', 'iforget'],
16+
['postgresql_marchantariats', 'postgresql', 'localhost', 'marchantariats', 'postgres', 'iforget'],
1717
['sqlite_wof', 'sqlite', './tests/spatialite/wof2odm/ODM2.sqlite', None, None, None]
1818
]
1919

0 commit comments

Comments
 (0)
Please sign in to comment.