diff --git a/Design.org b/Design.org index 7b7c894..d0ff030 100644 --- a/Design.org +++ b/Design.org @@ -45,20 +45,21 @@ CLOSED: [2019-11-01 Fri 00:34] - [X] Black box - [X] Entity-Relationship ** Implementation -*** TODO Backend [1/3] [33%] +*** TODO Backend [2/3] [66%] **** DONE Database [3/3] [100%] CLOSED: [2020-01-03 Fri 00:44] - [X] Connection - [X] Creation from script - [X] Creation of tables via class -**** TODO Parser [3/4] [75%] +**** DONE Parser [3/3] [100%] +CLOSED: [2020-01-08 Wed 03:18] - [X] Select useful fiels - [X] Convert PU to Country (ISO 3166) - [X] Insert into database -- [ ] Arithmetic operations for yearly changes -**** NEXT Flask framework [0/2] [0%] -- [ ] Plots with pandas +**** TODO Flask Application [0/2] [0%] - [ ] Login for admin +- [ ] Arithmetic operations for yearly changes +- [ ] Plots with pandas *** NEXT Documentation *** INACTIVE Frontend [0/1] [0%] - [ ] [[https://adminlte.io/][Adminlte]] diff --git a/code/database/db_setup.py b/code/database/db_setup.py index 2125837..7ed56f5 100644 --- a/code/database/db_setup.py +++ b/code/database/db_setup.py @@ -33,7 +33,6 @@ class Glacier(db.Model): country = db.Column(db.String(60)) name = db.Column(db.String(60)) annual_data = db.relationship("Annual_Data") - annual_change = db.relationship("Annual_Change") def __init__(self, uid, country, name): self.uid = uid @@ -56,20 +55,6 @@ class Annual_Data(db.Model): self.elevation = elevation -class Annual_Change(db.Model): - __tablename__ = "annual_change" - year = db.Column(db.Integer, db.ForeignKey("annual_data.year"), primary_key=True) - uid = db.Column(db.ForeignKey("glacier.uid"), primary_key=True) - surface_change = db.Column(db.Float) - length_change = db.Column(db.Float) - elevation_change = db.Column(db.Float) - - def __init__(self, surface_change, length_change, elevation_change): - self.surface_change = surface_change - self.length_change = length_change - self.elevation_change = elevation_change - - class User(db.Model): uid = db.Column(db.Integer, primary_key=True) registration_date = db.Column( diff --git a/code/database/export.py b/code/database/export.py index f77e4c9..5a72a65 100644 --- a/code/database/export.py +++ b/code/database/export.py @@ -16,7 +16,6 @@ def create_dataframes() -> DataFrame: files = { "glacier": "../data/glacier.csv", "annual_data": "../data/annual_data.csv", - "annual_change": "../data/annual_change.csv", "user": "../data/user.csv", } df_list = {} diff --git a/code/database/parser.py b/code/database/parser.py index 29df0cc..b79e043 100644 --- a/code/database/parser.py +++ b/code/database/parser.py @@ -55,13 +55,11 @@ def create_databases(df): files = { "glacier": "../data/glacier.csv", "annual_data": "../data/annual_data.csv", - "annual_change": "../data/annual_change.csv", "user": "../data/user.csv", } dataframes = { "glacier": df[["POLITICAL_UNIT", "NAME", "WGMS_ID"]].drop_duplicates(), "annual_data": df[["WGMS_ID", "YEAR", "AREA", "MEDIAN_ELEVATION", "LENGTH"]], - "annual_change": df[["WGMS_ID", "YEAR"]], "user": DataFrame(user), } renamed_dfs = rename_fields(dataframes) diff --git a/data/annual_change.csv b/data/annual_change.csv deleted file mode 100644 index 49c5c07..0000000 --- a/data/annual_change.csv +++ /dev/null @@ -1,1038 +0,0 @@ -"uid","year" -10452,2018 -2665,2014 -2665,2015 -2665,2016 -6833,2012 -878,2013 -3973,2013 -3367,2013 -3367,2014 -3367,2015 -3367,2016 -3366,2013 -3366,2014 -3366,2015 -3366,2016 -4532,2013 -4532,2016 -10453,2017 -922,2017 -2851,2016 -10455,2017 -10454,2017 -3903,2013 -3903,2015 -3591,2017 -4529,2013 -10457,2011 -10457,2016 -3902,2013 -3902,2015 -1675,2011 -1675,2013 -1675,2015 -1675,2018 -2848,2013 -2848,2015 -2848,2017 -3904,2013 -3904,2015 -3590,2017 -2000,2011 -2850,2016 -3589,2013 -4530,2013 -3593,2017 -4531,2013 -4528,2017 -2849,2013 -2849,2015 -2849,2017 -491,2011 -491,2013 -491,2014 -507,2013 -566,2013 -10460,2012 -489,2016 -2667,2012 -2667,2013 -2667,2014 -2667,2015 -2667,2016 -2667,2017 -1503,2012 -1503,2013 -1503,2014 -1503,2015 -1503,2016 -1503,2017 -39,2012 -39,2015 -39,2016 -39,2017 -2668,2014 -16,2012 -16,2015 -16,2016 -16,2017 -3690,2012 -3690,2015 -3690,2016 -3690,2017 -4534,2014 -0,2014 -5026,2011 -3801,2014 -3801,2017 -5132,2011 -5150,2011 -5277,2011 -5337,2011 -394,2012 -394,2017 -394,2018 -439,2011 -5736,2011 -5261,2011 -5250,2011 -5167,2011 -4573,2011 -5127,2011 -5454,2011 -5525,2011 -5531,2011 -463,2013 -463,2015 -463,2017 -5254,2011 -5311,2011 -5312,2011 -5330,2011 -5331,2011 -5255,2011 -5264,2011 -5310,2011 -5285,2011 -5288,2011 -5289,2011 -5278,2011 -5284,2011 -5287,2011 -5283,2011 -5142,2011 -1670,2011 -5182,2011 -5193,2011 -5191,2011 -436,2011 -1671,2011 -5735,2011 -5424,2011 -5528,2011 -2311,2011 -5248,2011 -5267,2011 -5266,2011 -5295,2011 -5258,2011 -5246,2011 -5276,2011 -5733,2011 -384,2011 -5153,2011 -5162,2011 -5160,2011 -5120,2011 -5342,2011 -5328,2011 -5343,2011 -5532,2011 -5158,2011 -2660,2013 -2660,2017 -366,2013 -366,2017 -4535,2017 -5234,2011 -5256,2011 -5315,2011 -5252,2011 -5262,2011 -5178,2011 -5188,2011 -5186,2011 -442,2011 -475,2011 -5137,2011 -5119,2011 -5194,2011 -5039,2011 -5237,2011 -471,2011 -4610,2011 -5341,2011 -5117,2011 -389,2014 -389,2017 -5042,2011 -5349,2011 -5355,2011 -5431,2011 -5432,2011 -5177,2011 -5176,2011 -5181,2011 -5189,2011 -5180,2011 -5336,2011 -5363,2011 -5299,2011 -440,2011 -5170,2011 -5428,2011 -5354,2011 -5124,2011 -367,2013 -367,2017 -367,2018 -5126,2011 -5298,2011 -5296,2011 -5297,2011 -359,2013 -359,2015 -359,2016 -359,2017 -359,2018 -2313,2011 -5318,2011 -5319,2011 -360,2011 -5118,2011 -5106,2011 -5249,2011 -4585,2011 -4586,2011 -5339,2011 -5340,2011 -5040,2011 -5019,2011 -5163,2011 -5159,2011 -5123,2011 -5357,2011 -5273,2011 -5409,2011 -5423,2011 -2314,2011 -5155,2011 -5128,2011 -5145,2011 -5200,2011 -5201,2011 -5281,2011 -3332,2012 -3332,2017 -5434,2011 -5199,2011 -5529,2011 -5731,2011 -4634,2011 -4633,2011 -5148,2011 -5147,2011 -5286,2011 -5245,2011 -5244,2011 -5179,2011 -5292,2011 -5270,2011 -5430,2011 -5161,2011 -5259,2011 -5260,2011 -5257,2011 -5282,2011 -5518,2011 -363,2011 -5169,2011 -5023,2011 -5022,2011 -5021,2011 -5187,2011 -5346,2011 -5347,2011 -5317,2011 -5457,2011 -5247,2011 -5324,2011 -5325,2011 -5323,2011 -5183,2011 -5202,2011 -5307,2011 -5730,2011 -5433,2011 -386,2011 -5043,2011 -5025,2011 -5024,2011 -5184,2011 -5268,2011 -5275,2011 -5265,2011 -5146,2011 -5198,2011 -5410,2011 -5429,2011 -5238,2011 -5151,2011 -470,2011 -5107,2011 -5131,2011 -5122,2011 -5164,2011 -5171,2011 -4339,2015 -4339,2016 -4339,2017 -5100,2011 -5101,2011 -5105,2011 -5114,2011 -5308,2011 -5309,2011 -5326,2011 -5327,2011 -5020,2011 -5272,2011 -5329,2011 -5303,2011 -5149,2011 -5138,2011 -451,2015 -5356,2011 -361,2011 -5134,2011 -5174,2011 -5517,2011 -5236,2011 -5362,2011 -4609,2011 -5116,2011 -5269,2011 -5190,2011 -5338,2011 -5322,2011 -5104,2011 -5115,2011 -5530,2011 -417,2014 -417,2016 -417,2017 -4246,2011 -4246,2015 -434,2011 -434,2017 -473,2013 -473,2015 -473,2017 -387,2011 -5519,2011 -462,2011 -5141,2011 -5173,2011 -5527,2011 -5168,2011 -5136,2011 -5335,2011 -5196,2011 -5197,2011 -5411,2011 -432,2014 -432,2016 -432,2017 -5251,2011 -5334,2011 -5018,2011 -5014,2011 -5453,2011 -5333,2011 -5263,2011 -5253,2011 -5133,2011 -5140,2011 -5515,2011 -4636,2011 -4635,2011 -5103,2011 -5102,2011 -4340,2014 -4340,2016 -4340,2017 -395,2012 -395,2017 -5279,2011 -5345,2011 -5352,2011 -5344,2011 -5351,2011 -5734,2011 -454,2013 -454,2016 -454,2017 -5732,2011 -5125,2011 -5144,2011 -2663,2011 -408,2013 -408,2015 -408,2016 -408,2017 -408,2018 -1672,2011 -5139,2011 -448,2011 -5526,2011 -5290,2011 -5113,2011 -5112,2011 -5041,2011 -5130,2011 -5314,2011 -5313,2011 -5152,2011 -5242,2011 -5241,2011 -5239,2011 -5240,2011 -5195,2011 -5017,2011 -5293,2011 -5294,2011 -5332,2011 -3428,2011 -5353,2011 -5348,2011 -5143,2011 -371,2013 -371,2017 -4611,2011 -5135,2011 -4613,2011 -5154,2011 -5157,2011 -4612,2011 -5426,2011 -5425,2011 -5274,2011 -5243,2011 -5536,2011 -5291,2011 -5166,2011 -5271,2011 -5175,2011 -5302,2011 -5301,2011 -5300,2011 -5305,2011 -5304,2011 -5516,2011 -5359,2011 -5320,2011 -2315,2011 -3430,2011 -3431,2011 -5358,2011 -5350,2011 -5361,2011 -5427,2011 -5728,2011 -5185,2011 -5165,2011 -5172,2011 -5121,2011 -5280,2011 -5316,2011 -5192,2011 -3432,2011 -5321,2011 -4412,2011 -3905,2013 -3905,2015 -4405,2011 -4407,2011 -4437,2011 -4382,2011 -1027,2011 -4403,2011 -4440,2011 -5870,2013 -4425,2011 -3983,2011 -3983,2012 -3983,2013 -3983,2014 -3983,2015 -4439,2011 -4421,2011 -4422,2012 -4423,2013 -2001,2011 -2001,2013 -2002,2011 -2002,2013 -4409,2011 -4438,2011 -4444,2011 -4432,2011 -4436,2011 -3445,2012 -3445,2013 -3445,2014 -3445,2015 -3445,2016 -3445,2017 -3445,2018 -4383,2011 -4435,2011 -4404,2011 -4384,2011 -4384,2013 -2004,2011 -2004,2013 -2003,2011 -2003,2013 -4416,2011 -4524,2011 -4414,2011 -3582,2011 -1041,2011 -1042,2011 -4406,2011 -2009,2011 -4419,2011 -18005,2011 -18006,2011 -10448,2013 -10445,2013 -10443,2013 -10450,2013 -10442,2013 -10441,2013 -10446,2013 -10440,2013 -10444,2013 -10449,2013 -10447,2013 -3992,2013 -10407,2014 -6846,2012 -3987,2011 -3987,2012 -3987,2013 -3987,2014 -3987,2015 -3987,2016 -869,2013 -12832,2013 -14640,2011 -14641,2011 -14642,2011 -14649,2011 -14650,2011 -14651,2011 -14652,2011 -14653,2011 -14654,2011 -14655,2011 -14656,2011 -14657,2011 -14658,2011 -14659,2011 -14660,2011 -14661,2011 -14662,2011 -14663,2011 -14664,2011 -14665,2011 -14666,2011 -14667,2011 -14668,2011 -14669,2011 -14670,2011 -14671,2011 -14672,2011 -14673,2011 -14674,2011 -14675,2011 -14692,2011 -14693,2011 -14694,2011 -14695,2011 -14696,2011 -14697,2011 -14698,2011 -14699,2011 -14700,2011 -14701,2011 -14702,2011 -14703,2011 -14704,2011 -14705,2011 -14706,2011 -14707,2011 -14708,2011 -14709,2011 -14710,2011 -14711,2011 -14712,2011 -14713,2011 -14714,2011 -14715,2011 -14716,2011 -14717,2011 -14718,2011 -14719,2011 -14720,2011 -14721,2011 -14722,2011 -14723,2011 -14724,2011 -14725,2011 -14726,2011 -14727,2011 -14728,2011 -14729,2011 -14730,2011 -14731,2011 -14732,2011 -14733,2011 -14734,2011 -14735,2011 -14736,2011 -14737,2011 -14738,2011 -14739,2011 -14740,2011 -14741,2011 -14742,2011 -14743,2011 -14744,2011 -14745,2011 -14746,2011 -14747,2011 -14748,2011 -14749,2011 -14750,2011 -14751,2011 -14756,2011 -14787,2011 -14790,2011 -14791,2011 -14792,2011 -14793,2011 -14794,2011 -14795,2011 -14796,2011 -14797,2011 -14798,2011 -14799,2011 -14800,2011 -14801,2011 -14802,2011 -14803,2011 -14804,2011 -14805,2011 -14806,2011 -14807,2011 -14808,2011 -14809,2011 -14810,2011 -14811,2011 -14812,2011 -14813,2011 -14814,2011 -14815,2011 -14832,2011 -14833,2011 -14834,2011 -14837,2011 -14841,2011 -15759,2011 -15816,2011 -15817,2011 -15818,2011 -15819,2011 -15820,2011 -15821,2011 -15822,2011 -15853,2011 -15854,2011 -15855,2011 -15856,2011 -15857,2011 -15858,2011 -15859,2011 -15860,2011 -15861,2011 -15862,2011 -15863,2011 -15864,2011 -15865,2011 -15910,2011 -15911,2011 -18004,2011 -18022,2011 -853,2012 -1511,2012 -1512,2012 -2721,2011 -2721,2012 -2721,2015 -2721,2016 -2721,2017 -2763,2011 -2763,2012 -2763,2013 -2763,2014 -2763,2015 -2763,2016 -2763,2017 -1624,2014 -1624,2016 -1624,2017 -942,2011 -942,2012 -942,2014 -942,2015 -942,2016 -2867,2011 -357,2014 -357,2018 -1314,2015 -767,2014 -4551,2014 -4548,2014 -4560,2014 -4561,2014 -765,2014 -1110,2014 -4562,2014 -766,2014 -4565,2014 -4543,2014 -4556,2014 -768,2014 -4545,2014 -4552,2014 -772,2014 -4559,2014 -783,2014 -1109,2014 -4549,2014 -4558,2014 -4555,2014 -4541,2014 -1111,2014 -4546,2014 -4537,2014 -769,2014 -4554,2014 -4536,2014 -4539,2014 -4547,2014 -4540,2014 -4553,2014 -4538,2014 -770,2014 -4564,2014 -4563,2014 -724,2014 -774,2014 -4550,2014 -4544,2014 -773,2014 -4557,2014 -10417,2014 -1629,2012 -4566,2015 -18783,2011 -18784,2011 -18007,2011 -18780,2011 -18781,2011 -18782,2011 -18785,2011 -18786,2011 -3088,2013 -3088,2014 -3088,2015 -3089,2015 -3090,2013 -3906,2011 -3660,2012 -1107,2012 -1107,2013 -1107,2014 -1107,2015 -1107,2016 -1107,2017 -1106,2011 -1106,2012 -1106,2017 -635,2012 -635,2013 -635,2015 -635,2017 -635,2018 -1507,2012 -661,2011 -661,2012 -661,2013 -1138,2011 -1138,2012 -672,2011 -672,2012 -672,2013 -672,2014 -672,2017 -675,2011 -675,2013 -675,2014 -675,2017 -645,2012 -2488,2011 -2488,2012 -2488,2017 -1282,2015 -693,2011 -732,2012 -732,2013 -732,2014 -732,2015 -732,2016 -781,2011 -781,2012 -781,2013 -781,2014 -781,2015 -781,2016 -781,2017 -781,2018 -829,2016 -829,2017 -829,2018 -3889,2011 -3889,2012 -3889,2013 -3889,2014 -3889,2015 -3889,2016 -3889,2017 -3889,2018 -10402,2015 -10402,2016 -753,2011 -753,2012 -753,2013 -753,2014 -753,2015 -753,2016 -753,2017 -753,2018 -813,2015 -813,2016 -813,2017 -813,2018 -805,2015 -805,2016 -805,2017 -805,2018 -817,2011 -817,2012 -817,2013 -817,2014 -817,2015 -817,2016 -817,2017 -3339,2013 -2671,2013 -1320,2013 -4568,2011 -3661,2011 -3661,2012 -3661,2013 -3661,2014 -3661,2015 -2295,2015 -2670,2011 -3343,2013 -3996,2012 -3997,2011 -1516,2011 -10401,2013 -912,2012 -1597,2011 -1597,2012 -1597,2013 -1597,2014 -1597,2015 -1597,2016 -1536,2013 -899,2014 -1538,2011 -1538,2013 -1538,2014 -1538,2015 -1538,2016 -3292,2012 -3292,2013 -3292,2017 -226,2012 -226,2013 -1617,2013 -1617,2015 -1617,2016 -726,2016 -726,2017 -761,2015 -761,2016 -761,2017 -761,2018 -344,2014 -333,2014 -330,2014 -329,2014 -1461,2014 -338,2014 -327,2014 -331,2014 -345,2014 -334,2014 -342,2014 -342,2015 -340,2014 -337,2014 -341,2014 -332,2014 -335,2014 -336,2014 -326,2014 -343,2014 -339,2014 -3812,2011 -3812,2012 -3812,2013 -3812,2014 -3812,2015 -3812,2016 -3812,2017 -3812,2018 -306,2011 -306,2012 -306,2013 -306,2014 -306,2015 -306,2016 -306,2017 -3479,2011 -305,2012 -305,2013 -305,2014 -305,2015 -305,2016 -2323,2011 -210,2014 -76,2012 -76,2013 -76,2015 -83,2012 -83,2013 -83,2015 -83,2017 -83,2018 -1367,2012 -1367,2013 -1367,2015 -1367,2017 -1367,2018 -188,2014 -203,2012 -203,2013 -203,2014 -84,2012 -84,2013 -90,2012 -90,2013 -90,2014 -90,2015 -90,2016 -90,2018 -82,2012 -82,2013 -82,2015 -82,2017 -82,2018 -3334,2012 -3334,2013 -3334,2015 -3334,2016 -3334,2018 -77,2012 -77,2013 -77,2015 -77,2017 -77,2018 -81,2012 -81,2013 -81,2015 -81,2017 -81,2018 -201,2012 -201,2013 -201,2014 -1666,2012 -1666,2013 -1666,2014 -1664,2012 -1664,2013 -1664,2014 -79,2012 -79,2013 -79,2015 -1667,2012 -1667,2013 -1667,2014 -3295,2012 -3295,2013 -3295,2015 -3295,2017 -3295,2018 -1665,2012 -1665,2013 -1665,2014 -205,2013 -205,2014 -205,2015 -205,2018 -218,2013 -218,2015 -124,2012 -124,2013 -124,2015 -124,2017 -124,2018 -94,2012 -94,2013 -94,2014 -94,2015 -94,2016 -94,2018 -75,2012 -75,2013 -75,2015 -75,2017 -75,2018