Skip to content

Commit 6def5ec

Browse files
Fixing Scree Graph
1 parent 28f63ff commit 6def5ec

9 files changed

+26
-1027
lines changed

FTSExample/FTSExample.ipynb

-1,012
This file was deleted.

FillingTimeSeries/FillingMethods.py

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Note: V 0.9.1 Originally, filling data methods was developed by Eric Alfaro and Javier Soley in SCILAB
2+
Note: V 0.9.2 Originally, filling data methods was developed by Eric Alfaro and Javier Soley in SCILAB
33
Python version was developed by Rolando Duarte and Erick Rivera
44
Centro de Investigaciones Geofísicas (CIGEFI)
55
Universidad de Costa Rica (UCR)
@@ -154,25 +154,33 @@ def checkPrincipalComponents(self):
154154
upperError: int
155155
Maximum value to choose principal components
156156
"""
157+
#Scalating to get the best performance using PCA
157158
scale = StandardScaler()
158159
dfMeanScaled = scale.fit_transform(self.dfMean)
159160
pca = PCA(n_components = self.dfColumns, copy = True, svd_solver = "full", random_state = 0)
160-
pca.fit(dfMeanScaled)
161+
vectorsPCA = pca.fit_transform(dfMeanScaled)
161162
explainedVariance = pca.explained_variance_
162-
errorExplainedVarience = explainedVariance * sqrt(2 / self.dfRows)
163+
errorExplainedVarience = []
164+
165+
#Calculating error bars
166+
for index in arange(0, len(explainedVariance)):
167+
dfComponents = DataFrame({"Original": vectorsPCA[:, index]})
168+
dfComponents["Shift"] = dfComponents.Original.shift(1)
169+
corr = dfComponents.corr().iloc[0, 1]
170+
nEffective = self.dfRows * (1 - corr**2) / (1 + corr**2)
171+
errorExplainedVarience.append(explainedVariance[index] * sqrt(2 / nEffective))
163172
components = arange(1, len(explainedVariance) + 1)
164173
upperError = len(explainedVariance) - 1
165174

166-
figure(figsize = (20, 20))
175+
#Plotting eigenvalues and principal components
167176
errorbar(components, explainedVariance,
168-
yerr=errorExplainedVarience, fmt="o", color="#9b6dff",
169-
ecolor="black", capsize=6,
177+
yerr=errorExplainedVarience, fmt="D", color="green",
178+
ecolor="red", capsize=10,
170179
)
171180
title("Explained variance vs. principal components")
172181
xlabel("Principal components")
173182
ylabel("Explained variance")
174183
show()
175-
176184
return upperError
177185

178186
def PCAMethod(self, components=1, tol=1e-1, itermax=10, valueMin=0.0):
@@ -247,7 +255,8 @@ def checkPrincipalComponents(self):
247255
upperError: int
248256
Maximum value to choose principal components
249257
"""
250-
return PrincipalComponentAnalysis(self.df).checkPrincipalComponents()
258+
upperError = PrincipalComponentAnalysis(self.df).checkPrincipalComponents()
259+
return upperError
251260

252261
def FullMethod(self, lags=1, components=1, tol=1e-1, itermax=10, valueMin=0.0):
253262
"""

FillingTimeSeries/PreprocessingFillingMethods.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Note: V 0.9.1 Originally, filling data methods was developed by Eric Alfaro and Javier Soley in SCILAB
2+
Note: V 0.9.2 Originally, filling data methods was developed by Eric Alfaro and Javier Soley in SCILAB
33
Python version was developed by Rolando Duarte and Erick Rivera
44
Centro de Investigaciones Geofísicas (CIGEFI)
55
Universidad de Costa Rica (UCR)

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Filling Time Series (v.0.9.1)
1+
# Filling Time Series (v.0.9.2)
22

33
## Filling missing values in geophysical time series
44

@@ -10,9 +10,7 @@
1010
Filling Time Series is a Python package to help the users to work with geophysical time series by filling missing values in their data. Filling Time Series was developed at the Centro de Investigaciones Geofísicas (CIGEFI), Universidad de Costa Rica (UCR).
1111

1212
## Last updates
13-
- Added new method: ComponentsAutoregression applies autoregression method, then, the principal components method to fill the time series.
14-
- Small fixes in the Scree graph.
15-
- Renaming some classes, please, check documentation.
13+
- Fixing the error bar calculation.
1614

1715
## Documentation
1816
Documentation will be available soon.
@@ -44,6 +42,10 @@ Bug reports can be submitted to the issue tracker at:
4442

4543
[https://github.com/rolandojduartem/FillingTimeSeries/issues](https://github.com/rolandojduartem/FillingTimeSeries/issues)
4644

45+
## References
46+
- Alfaro, E., & Soley, J. (2009). Descripción de dos métodos de rellenado de datos ausentes en series de tiempo metereológicos. Revista de matemática: Teoría y Aplicaciones, 16, 60 - 75.
47+
- Ureña, P., Alfaro, E., & Soley, J. (2016). Propuestas metodológicas para el rellenado de datos ausentes en series de tiempo geofísicas. Guía Práctica de uso. Universidad de Costa Rica.
48+
4749
## License
4850

4951
MIT License
-9.14 KB
Binary file not shown.

dist/FillingTimeSeries-0.9.1.tar.gz

-6.47 KB
Binary file not shown.
9.42 KB
Binary file not shown.

dist/FillingTimeSeries-0.9.2.tar.gz

6.82 KB
Binary file not shown.

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
setup(
88
name = 'FillingTimeSeries',
99
packages = ['FillingTimeSeries'],
10-
version = '0.9.1',
10+
version = '0.9.2',
1111
license='MIT', # License from here: https://help.github.com/articles/licensing-a-repository
1212
description = 'Filling Time series: Package to fill missing values in geophysical time series in Python', # Short description
1313
long_description = long_description,
1414
long_description_content_type = "text/markdown",
1515
author = 'Rolando Jesus Duarte Mejias, Erick Rivera Fernandez',
1616
author_email = 'rolando.duartemejias@ucr.ac.cr',
1717
url = 'https://github.com/rolandojduartem/FillingTimeSeries', # github or website
18-
download_url = 'https://github.com/rolandojduartem/FillingTimeSeries/archive/refs/tags/v_0_9_1.tar.gz', # Download file
18+
download_url = 'https://github.com/rolandojduartem/FillingTimeSeries/archive/refs/tags/v_0_9_2.tar.gz', # Download file
1919
keywords = ['Time Series', 'Missing values', 'Metereology', "Geophysics", "Metereological"],
2020
setup_requires=['wheel'],
2121
install_requires=[ # I get to this in a second

0 commit comments

Comments
 (0)