Browse Source

initial parse of yaml

Konstantin Ladutenko 5 years ago
parent
commit
53fde0bb0c

+ 1 - 4
vue-cli3-webapp/package-lock.json

@@ -2027,7 +2027,6 @@
       "version": "1.0.10",
       "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
       "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
-      "dev": true,
       "requires": {
         "sprintf-js": "~1.0.2"
       }
@@ -5158,8 +5157,7 @@
     "esprima": {
       "version": "4.0.1",
       "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
-      "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
-      "dev": true
+      "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
     },
     "esquery": {
       "version": "1.0.1",
@@ -8356,7 +8354,6 @@
       "version": "3.13.1",
       "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
       "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
-      "dev": true,
       "requires": {
         "argparse": "^1.0.7",
         "esprima": "^4.0.0"

+ 1 - 0
vue-cli3-webapp/package.json

@@ -11,6 +11,7 @@
     "buefy": "^0.8.0",
     "plotly.js": "^1.33.0",
     "core-js": "^3.4.3",
+    "js-yaml": "^3.13.1",
     "vue": "^2.6.10"
   },
   "devDependencies": {

+ 58 - 0
vue-cli3-webapp/public/Ag-Johnson-1972.yml

@@ -0,0 +1,58 @@
+# this file is part of refractiveindex.info database
+# refractiveindex.info database is in the public domain
+# copyright and related rights waived via CC0 1.0
+
+REFERENCES: "P. B. Johnson and R. W. Christy. Optical constants of the noble metals, <a href=\"https://doi.org/10.1103/PhysRevB.6.4370\"><i>Phys. Rev. B</i> <b>6</b>, 4370-4379 (1972)</a>"
+COMMENTS: "Room temperature"
+DATA:
+  - type: tabulated nk
+    data: |
+        0.1879 1.07 1.212
+        0.1916 1.10 1.232
+        0.1953 1.12 1.255
+        0.1993 1.14 1.277
+        0.2033 1.15 1.296
+        0.2073 1.18 1.312
+        0.2119 1.20 1.325
+        0.2164 1.22 1.336
+        0.2214 1.25 1.342
+        0.2262 1.26 1.344
+        0.2313 1.28 1.357
+        0.2371 1.28 1.367
+        0.2426 1.30 1.378
+        0.2490 1.31 1.389
+        0.2551 1.33 1.393
+        0.2616 1.35 1.387
+        0.2689 1.38 1.372
+        0.2761 1.41 1.331
+        0.2844 1.41 1.264
+        0.2924 1.39 1.161
+        0.3009 1.34 0.964
+        0.3107 1.13 0.616
+        0.3204 0.81 0.392
+        0.3315 0.17 0.829
+        0.3425 0.14 1.142
+        0.3542 0.10 1.419
+        0.3679 0.07 1.657
+        0.3815 0.05 1.864
+        0.3974 0.05 2.070
+        0.4133 0.05 2.275
+        0.4305 0.04 2.462
+        0.4509 0.04 2.657
+        0.4714 0.05 2.869
+        0.4959 0.05 3.093
+        0.5209 0.05 3.324
+        0.5486 0.06 3.586
+        0.5821 0.05 3.858
+        0.6168 0.06 4.152
+        0.6595 0.05 4.483
+        0.7045 0.04 4.838
+        0.7560 0.03 5.242
+        0.8211 0.04 5.727
+        0.8920 0.04 6.312
+        0.9840 0.04 6.992
+        1.0880 0.04 7.795
+        1.2160 0.09 8.828
+        1.3930 0.13 10.10
+        1.6100 0.15 11.85
+        1.9370 0.24 14.08

BIN
vue-cli3-webapp/public/favicon.ico


+ 40 - 0
vue-cli3-webapp/src/App.vue

@@ -284,6 +284,46 @@
         this.plotResults();
         this.isLoading = false;
       }
+
+      const yaml = require('js-yaml');
+      // const fs   = require('fs');
+      // Get document, or throw exception on error
+      let Ag_data;
+      // function csvToArray (csv) {
+      //   let rows = csv.split("\n");
+      //
+      //   return rows.map(function (row) {
+      //     return row.split(" ");
+      //   })
+      // }
+
+      try {
+        fetch('Ag-Johnson-1972.yml').then(response =>
+                response.text().then(function(text) {
+                  Ag_data = text;
+                  const doc = yaml.safeLoad(Ag_data);
+                  if (doc.DATA[0].type == "tabulated nk") {
+                    let csv = doc.DATA[0].data;
+                    let rows = csv.split("\n");
+
+                    let data =  rows.map(function (row) {
+                      return row.split(" ");
+                    });
+                    let data_num = data.map(function(elem) {
+                      return elem.map(function(elem2) {
+                        return parseFloat(elem2);
+                      });
+                    })
+                    console.log( data_num
+                    );
+                  }
+                })
+        );
+        //
+        // console.log(doc);
+      } catch (e) {
+        console.log(e);
+      }
     },
     watch: {
       plotSelector: {

+ 4 - 5
vue-cli3-webapp/src/components/GetLayerParameters.vue

@@ -31,7 +31,7 @@
                     <b-select v-model="layer.material">
                         <option value="nk">nk-constant</option>
                         <option value="popular">popular</option>
-                        <option value="web">refractiveindex.info</option>
+                        <option value="web" disabled>refractiveindex.info</option>
                     </b-select>
 
                 </div>
@@ -48,12 +48,11 @@
                     <input-with-units title="Re(n)" units=""
                                       v-bind:value="layer.reN"
                                       @newdata="layer.reN=$event"
-                                      v-bind:isDisabled="isDisabled"
-                    />
+                                      v-bind:isDisabled="isDisabled"/>
                     <input-with-units title="Im(n)" units=""
                                       v-bind:value="layer.imN"
-                                      @newdata="layer.imN=$event"/>
-
+                                      @newdata="layer.imN=$event"
+                                      v-bind:isDisabled="isDisabled"/>
                 </div>
             </div>
         </div>