iRSSの日記

はてなダイアリーiRSSの日記の続き

カーボンファーミング- 炭素農法

炭素を蓄積を増やしながら農業する。

緑肥や不耕起により炭素を土壌に貯留しようとする農法

炭素循環農法と炭素農法

前者は「無肥料(木材等これまで肥料と思われてなかった資材や緑肥を投入するので、何も入れない訳ではない)無農薬で、農作物を作ろう」ということで、後者は、炭素循環農法とほとんど同じなんだけど、農業を営む中で、土壌中に蓄積される炭素を増加させようということを主眼しているような印象。

https://www.maff.go.jp/j/kokusai/kokkyo/platform/pdf/platform-172.pdf

カーボンファーミング(Carbon Farming)とは、大気中の CO2 を土壌に取り込んで、農地の土壌 の質を向上させ温室効果ガスの排出削減を目指す農法で、いわゆる環境再生型農業を指す。

https://www.maff.go.jp/j/kokusai/kokkyo/platform/pdf/platform-172.pdf

https://www.maff.go.jp/j/council/seisaku/kikaku/goudou/13/pdf/data3_3.pdf

https://www.maff.go.jp/j/council/seisaku/kikaku/goudou/13/pdf/data3_3.pdf

www.naro.affrc.go.jp

我が国の農地、特に水田や黒ボク土畑においても土壌炭素量の変化を精度良く計算できる土壌炭素動態モデルの日本版「改良RothCモデル」を開発しました。 さらに、そのモデルに環境情報のデータや農業活動のシナリオを入力することにより、我が国農地における土壌炭素量の変化を全国規模で計算できるシステムを開発しました。 このシステムによる計算の結果、我が国農地の土壌炭素量は減少しているものの、京都議定書に基づく国際的なルールの下で、農地土壌における二酸化炭素(CO2)吸収(炭素貯留)を期待できることが明らかになりました。

ここまでわかった自然栽培

自然栽培の歴史は浅く、栽培技術も未熟である。 「無肥料、無農薬栽培」び研究をした人はまだ少数

「土壌は植物を支持する物理的空間であり、作物を持続的に栽培するには肥料として外部から栄養塩を補給することが不可欠である」 という考え方だと、無肥料でも作物が収穫できる農地の説明ができない。

「土壌は外部に持ち出された栄養塩を自律的に共有する能力を持つ生態系である」

という考え方が必要。

なるほど。

無肥料でどうやったら 野菜ができるの?

www.a.u-tokyo.ac.jp https://www.a.u-tokyo.ac.jp/pr-yayoi/64f2.pdf 17年春の文献、その後どうなったのかなあ

https://utf.u-tokyo.ac.jp/project/pjt159 見つけました。 宮沢先生活動継続中。 畑と森を再生する糸状菌の活性化基金​ プロジェクト推進されてます。期待!

form内の入力項目数の残りを取得して、ユーザーにあとどれくらいで終わるのかを伝えたい

form内の入力項目数の残りを取得して、ユーザーにあとどれくらいで終わるのかを伝えたいときに、

20/30 あと10件

というメッセージを出そうと思う

このとき、ページ内の項目数をどのようにして、取得するかが、問題になる。 手動で、ひとつふたつと数えても良いのだけど、項目数が多いと、正確に数えるのが難しい。

自動的に算出する方法を考えてみる。

form内に存在する、ユーザーにとって、入力可能な項目とは何か?

formなので、input, texarea, select のいずれかとする。

とすると、対象となる、要素を取得するにはinput type= hidden と 見えない要素を除いてあげて、nameの重複を排除すれば、数は出せそうだ。

[...new Set(Array.from(document.querySelectorAll("select,radio,input:not([type='hidden'])")).map((e) =>{return JSON.stringify({name: e.name, hidden: e.clientHeight === 0})}))].map(v => JSON.parse(v)

ただ、select,radio,inputがe.clientHeight=0であるが、 JSを使って値をセットする場合は、見えないからといって、カウントしないわけにもいかない。

ソーラーパネルのテスト

ソーラーパネルからのバッテリーへの充電ができなくなったので、調査

バッテリーは エコフローDELTA mini

ソーラーパネルからの出力

電圧

f:id:iRSS:20220314110041j:plain
接続しないと0V
f:id:iRSS:20220314110028j:plain
日陰だと6V
f:id:iRSS:20220314110005j:plain
日当たり最高で21V

発電はしている模様

電流 ソーラーパネルをDELTA miniに接続後、電流測定

f:id:iRSS:20220314110902j:plain
接続しないと0
f:id:iRSS:20220314110857j:plain
日当たり最高で200mA

DELTA mini

f:id:iRSS:20220314111539j:plain
DELTA miniの前面パネルは0Wの表示のまま

firebase-functions-testのテストが通らない時

事象

github.com

Cloud Firestore セキュリティ ルールをfirebase-functions-testの unit testを jestで走らせようとしたら Cannot use import statement outside a module というエラーがでた。

 FAIL  src/__test__/rules/firestore.rules.spec.ts
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
     • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    /Users/takaofunami/src/aid/firesync/fire2pg/functions/node_modules/firebase/compat/database/dist/index.esm.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import '@firebase/database-compat';
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
      at Object.<anonymous> (node_modules/@firebase/rules-unit-testing/dist/index.cjs.js:5:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.248 s, estimated 1 s
Ran all test suites related to changed files.

原因の推定

jest-node-exports-resolverのパス推測がよろしくない模様。jest-node-exports-resolveを外して、defaultResolverを使えば、動いた

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */

module.exports = {
  testEnvironment: "node",
  moduleNameMapper: {
    "^src/(.*)$": "<rootDir>/src/$1",
    "^@/(.*)$": "<rootDir>/src/$1",
  },
  verbose: true,
  testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$",
  resolver: "jest-node-exports-resolver",
  modulePaths: ["node_modules"],
};

解決策

特定のモジュールだけ、jest-node-exports-resolverではなくてdefaultResolverにして、解決できた

jest.condif.ts

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */

module.exports = {
  testEnvironment: "node",
  moduleNameMapper: {
    "^src/(.*)$": "<rootDir>/src/$1",
    "^@/(.*)$": "<rootDir>/src/$1",
  },
  verbose: true,
  testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.[jt]sx?$",
  resolver: "<rootDir>/resolver.js",
  modulePaths: ["node_modules"],
};

resolver.js

const jest_node_exports_resolver = require("jest-node-exports-resolver");

module.exports = (request, options) => {
  if (request.match(/^(@firebase|firebase)\//)) {
    // qconsole.log({ request, options });
    return options.defaultResolver(request, options);
  } else return jest_node_exports_resolver(request, options);
};